Updated on 2026-08-14
This commit is contained in:
parent
68503f3a51
commit
55fcdc6e83
5 changed files with 29 additions and 17 deletions
|
|
@ -196,6 +196,8 @@ internal class AppSettingsViewModel(
|
|||
appCurrencyRepository
|
||||
.getSelectedAppCurrency()
|
||||
.onEach {
|
||||
if (it.code == store.state.globalState.appCurrency.code) return@onEach
|
||||
|
||||
val fiatCurrency = with(it) { FiatCurrency(code, name, symbol) }
|
||||
store.dispatchWithMain(DetailsAction.AppSettings.ChangeAppCurrency(fiatCurrency))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ package com.tangem.data.common.cache
|
|||
|
||||
import com.tangem.datasource.local.cache.CacheKeysStore
|
||||
import com.tangem.datasource.local.cache.model.CacheKey
|
||||
import kotlinx.coroutines.NonCancellable
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.joda.time.Duration
|
||||
import org.joda.time.LocalDateTime
|
||||
import timber.log.Timber
|
||||
|
|
@ -20,17 +22,17 @@ internal class DefaultCacheRegistry(
|
|||
|
||||
override suspend fun invalidate(key: String) {
|
||||
Timber.d("Invalidate the cache key: $key")
|
||||
cacheKeysStore.remove(key)
|
||||
withContext(NonCancellable) { cacheKeysStore.remove(key) }
|
||||
}
|
||||
|
||||
override suspend fun invalidate(keys: Collection<String>) {
|
||||
Timber.d("Invalidate cache keys: $keys")
|
||||
cacheKeysStore.remove(keys)
|
||||
withContext(NonCancellable) { cacheKeysStore.remove(keys) }
|
||||
}
|
||||
|
||||
override suspend fun invalidateAll() {
|
||||
Timber.d("Invalidate all cache keys")
|
||||
cacheKeysStore.clear()
|
||||
withContext(NonCancellable) { cacheKeysStore.clear() }
|
||||
}
|
||||
|
||||
override suspend fun invokeOnExpire(
|
||||
|
|
@ -44,18 +46,22 @@ internal class DefaultCacheRegistry(
|
|||
|
||||
try {
|
||||
Timber.d("Invoke the action associated with the cache key: $key")
|
||||
|
||||
cacheKeysStore.store(
|
||||
key = CacheKey(
|
||||
id = key,
|
||||
updatedAt = LocalDateTime.now(),
|
||||
expiresIn = expireIn,
|
||||
),
|
||||
)
|
||||
|
||||
block()
|
||||
} catch (e: Throwable) {
|
||||
Timber.w(e, "The action related to the cache key has failed: $key")
|
||||
Timber.e(e, "The action related to the cache key has failed: $key")
|
||||
|
||||
invalidate(key)
|
||||
|
||||
throw e
|
||||
}
|
||||
|
||||
cacheKeysStore.store(
|
||||
key = CacheKey(
|
||||
id = key,
|
||||
updatedAt = LocalDateTime.now(),
|
||||
expiresIn = expireIn,
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -97,7 +97,9 @@ internal class DefaultNetworksRepository(
|
|||
extraTokens = currencies.filterIsInstance<CryptoCurrency.Token>().toSet(),
|
||||
)
|
||||
|
||||
invalidateCacheKeyIfNeeded(userWalletId, network, result)
|
||||
withContext(NonCancellable) {
|
||||
invalidateCacheKeyIfNeeded(userWalletId, network, result)
|
||||
}
|
||||
|
||||
val networkStatus = networkStatusFactory.createNetworkStatus(
|
||||
network = network,
|
||||
|
|
|
|||
|
|
@ -35,9 +35,11 @@ internal class DefaultQuotesRepository(
|
|||
}
|
||||
|
||||
withContext(dispatchers.io) {
|
||||
selectedAppCurrencyStore.get().collectLatest { appCurrency ->
|
||||
fetchExpiredQuotes(currenciesIds, appCurrency.id, refresh = false)
|
||||
}
|
||||
selectedAppCurrencyStore.get()
|
||||
.distinctUntilChanged()
|
||||
.collectLatest { appCurrency ->
|
||||
fetchExpiredQuotes(currenciesIds, appCurrency.id, refresh = false)
|
||||
}
|
||||
}
|
||||
}.cancellable()
|
||||
|
||||
|
|
|
|||
|
|
@ -298,7 +298,7 @@ internal class WalletViewModel @Inject constructor(
|
|||
update = { it.copy(scanResponse = scannedCardResponse) },
|
||||
)
|
||||
.onRight {
|
||||
fetchTokenListUseCase(userWalletId = it.walletId, refresh = true)
|
||||
fetchTokenListUseCase(userWalletId = it.walletId)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue