delete conversation cache on logout (#1037)
* delete conversation cache on logout * use correct threading method
This commit is contained in:
parent
d03751e59c
commit
26fb9e3ccf
@ -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();
|
||||
|
||||
|
@ -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,6 +95,13 @@ 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<Conversation>?) {
|
||||
result?.let { conversations ->
|
||||
db.conversationDao().insert(conversations.map { it.toEntity(accountId) })
|
||||
|
Loading…
Reference in New Issue
Block a user