diff --git a/app/src/main/java/com/keylesspalace/tusky/MainActivity.java b/app/src/main/java/com/keylesspalace/tusky/MainActivity.java index 87bcf017..2c4c7dfa 100644 --- a/app/src/main/java/com/keylesspalace/tusky/MainActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/MainActivity.java @@ -40,6 +40,7 @@ import com.keylesspalace.tusky.appstore.CacheUpdater; import com.keylesspalace.tusky.appstore.EventHub; import com.keylesspalace.tusky.appstore.MainTabsChangedEvent; import com.keylesspalace.tusky.appstore.ProfileEditedEvent; +import com.keylesspalace.tusky.components.conversation.ConversationsRepository; import com.keylesspalace.tusky.db.AccountEntity; import com.keylesspalace.tusky.entity.Account; import com.keylesspalace.tusky.interfaces.ActionButtonActivity; @@ -103,6 +104,8 @@ public final class MainActivity extends BottomSheetActivity implements ActionBut public EventHub eventHub; @Inject public CacheUpdater cacheUpdater; + @Inject + ConversationsRepository conversationRepository; private FloatingActionButton composeButton; private AccountHeader headerResult; @@ -472,6 +475,7 @@ public final class MainActivity extends BottomSheetActivity implements ActionBut NotificationHelper.deleteNotificationChannelsForAccount(accountManager.getActiveAccount(), MainActivity.this); cacheUpdater.clearForUser(activeAccount.getId()); + conversationRepository.deleteCacheForAccount(activeAccount.getId()); AccountEntity newAccount = accountManager.logActiveAccountOut(); diff --git a/app/src/main/java/com/keylesspalace/tusky/components/conversation/ConversationsRepository.kt b/app/src/main/java/com/keylesspalace/tusky/components/conversation/ConversationsRepository.kt index 37c5fd42..c99adc2a 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/conversation/ConversationsRepository.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/conversation/ConversationsRepository.kt @@ -11,6 +11,8 @@ import com.keylesspalace.tusky.entity.Conversation import com.keylesspalace.tusky.network.MastodonApi import com.keylesspalace.tusky.util.Listing import com.keylesspalace.tusky.util.NetworkState +import io.reactivex.Single +import io.reactivex.schedulers.Schedulers import retrofit2.Call import retrofit2.Callback import retrofit2.Response @@ -93,9 +95,16 @@ class ConversationsRepository @Inject constructor(val mastodonApi: MastodonApi, ) } + fun deleteCacheForAccount(accountId: Long) { + Single.fromCallable { + db.conversationDao().deleteForAccount(accountId) + }.subscribeOn(Schedulers.io()) + .subscribe() + } + private fun insertResultIntoDb(accountId: Long, result: List?) { result?.let { conversations -> - db.conversationDao().insert(conversations.map { it.toEntity(accountId) }) + db.conversationDao().insert(conversations.map { it.toEntity(accountId) }) } } } \ No newline at end of file