1
0
mirror of https://github.com/wulkanowy/wulkanowy.git synced 2024-09-20 04:29:09 -05:00

Fix admin messages caching (#1632)

This commit is contained in:
Mikołaj Pich 2021-11-13 19:50:26 +01:00 committed by GitHub
parent 10cb2b70f1
commit 6de937703a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,7 +5,6 @@ import io.github.wulkanowy.data.db.dao.AdminMessageDao
import io.github.wulkanowy.data.db.entities.Student
import io.github.wulkanowy.utils.AppInfo
import io.github.wulkanowy.utils.AutoRefreshHelper
import io.github.wulkanowy.utils.getRefreshKey
import io.github.wulkanowy.utils.networkBoundResource
import kotlinx.coroutines.sync.Mutex
import javax.inject.Inject
@ -27,7 +26,7 @@ class AdminMessageRepository @Inject constructor(
query = { adminMessageDao.loadAll() },
fetch = { adminMessageService.getAdminMessages() },
shouldFetch = {
refreshHelper.shouldBeRefreshed(getRefreshKey(cacheKey, student)) || forceRefresh
refreshHelper.shouldBeRefreshed(cacheKey) || forceRefresh
},
saveFetchResult = { oldItems, newItems ->
adminMessageDao.removeOldAndSaveNew(oldItems, newItems)