mirror of
https://github.com/LiveFastEatTrashRaccoon/RaccoonForLemmy.git
synced 2025-02-09 09:28:42 +01:00
fix: Lemmy value cache refresh with no connection (#1120)
This commit is contained in:
parent
2789408aa7
commit
573068cdbb
@ -1,11 +1,11 @@
|
||||
package com.github.diegoberaldin.raccoonforlemmy.domain.lemmy.repository
|
||||
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.api.dto.GetSiteResponse
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.api.provider.ServiceProvider
|
||||
import com.github.diegoberaldin.raccoonforlemmy.domain.lemmy.repository.utils.toAuthHeader
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.update
|
||||
|
||||
// TODO: add tests
|
||||
internal class DefaultLemmyValueCache(
|
||||
private val services: ServiceProvider,
|
||||
) : LemmyValueCache {
|
||||
@ -16,10 +16,12 @@ internal class DefaultLemmyValueCache(
|
||||
|
||||
override suspend fun refresh(auth: String?) {
|
||||
val response =
|
||||
services.site.get(
|
||||
auth = auth,
|
||||
authHeader = auth.toAuthHeader(),
|
||||
)
|
||||
runCatching {
|
||||
services.site.get(
|
||||
auth = auth,
|
||||
authHeader = auth.toAuthHeader(),
|
||||
)
|
||||
}.getOrElse { GetSiteResponse() }
|
||||
isDownVoteEnabled.update {
|
||||
response.siteView?.localSite?.enableDownvotes == true
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user