Improve timeline dao (#2353)

* improve TimelineDao methods

* remove @Transaction from cleanup methods
This commit is contained in:
Konrad Pozniak 2022-03-02 20:40:06 +01:00 committed by GitHub
commit 497b434663
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 35 additions and 26 deletions

View file

@ -3,9 +3,7 @@ package com.keylesspalace.tusky.appstore
import com.google.gson.Gson
import com.keylesspalace.tusky.db.AccountManager
import com.keylesspalace.tusky.db.AppDatabase
import io.reactivex.rxjava3.core.Single
import io.reactivex.rxjava3.disposables.Disposable
import io.reactivex.rxjava3.schedulers.Schedulers
import javax.inject.Inject
class CacheUpdater @Inject constructor(
@ -47,12 +45,7 @@ class CacheUpdater @Inject constructor(
this.disposable.dispose()
}
fun clearForUser(accountId: Long) {
Single.fromCallable {
appDatabase.timelineDao().removeAllForAccount(accountId)
appDatabase.timelineDao().removeAllUsersForAccount(accountId)
}
.subscribeOn(Schedulers.io())
.subscribe()
suspend fun clearForUser(accountId: Long) {
appDatabase.timelineDao().removeAll(accountId)
}
}