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

@ -70,7 +70,7 @@ class CachedTimelineViewModel @Inject constructor(
override val statuses = Pager(
config = PagingConfig(pageSize = LOAD_AT_ONCE),
remoteMediator = CachedTimelineRemoteMediator(accountManager, api, db, gson),
pagingSourceFactory = { db.timelineDao().getStatusesForAccount(accountManager.activeAccount!!.id) }
pagingSourceFactory = { db.timelineDao().getStatuses(accountManager.activeAccount!!.id) }
).flow
.map { pagingData ->
pagingData.map { timelineStatus ->
@ -214,10 +214,7 @@ class CachedTimelineViewModel @Inject constructor(
override fun fullReload() {
viewModelScope.launch {
val activeAccount = accountManager.activeAccount!!
db.runInTransaction {
db.timelineDao().removeAllForAccount(activeAccount.id)
db.timelineDao().removeAllUsersForAccount(activeAccount.id)
}
db.timelineDao().removeAll(activeAccount.id)
}
}