Collections fragment: cache paging data (bitfireAT/davx5#206)

Closes bitfireAT/davx5#205
This commit is contained in:
Ricki Hirner 2023-02-04 20:13:08 +01:00
parent 179602df46
commit 1dd93ae43a
No known key found for this signature in database
GPG key ID: 79A019FCAAEDD3AA

View file

@ -285,7 +285,7 @@ abstract class CollectionsFragment: Fragment(), SwipeRefreshLayout.OnRefreshList
val collectionColors = db.collectionDao().colorsByServiceLive(serviceId)
val collections: LiveData<PagingData<Collection>> =
Transformations.switchMap(accountModel.showOnlyPersonal) { onlyPersonal ->
Pager(
val pager = Pager(
PagingConfig(pageSize = 25),
pagingSourceFactory = {
Logger.log.info("Creating new pager onlyPersonal=$onlyPersonal")
@ -296,7 +296,10 @@ abstract class CollectionsFragment: Fragment(), SwipeRefreshLayout.OnRefreshList
// show all collections
db.collectionDao().pageByServiceAndType(serviceId, collectionType)
}
).liveData
)
return@switchMap pager
.liveData
.cachedIn(viewModelScope)
}
// observe RefreshCollectionsWorker status