Updated on 2026-08-14

This commit is contained in:
Tangem 2025-02-20 14:50:16 +04:00
parent fde7ec8688
commit 111dea42be
11 changed files with 97 additions and 44 deletions

View file

@ -50,6 +50,7 @@ internal class DefaultNetworksRepository(
networks: Set<Network>,
): Flow<Set<NetworkStatus>> {
return networksStatusesStore.get(userWalletId, networks)
.distinctUntilChanged()
.flowOn(dispatchers.io)
}
@ -120,17 +121,7 @@ internal class DefaultNetworksRepository(
refresh: Boolean,
) = coroutineScope {
if (refresh) {
val statusesToRefresh = networksStatusesStore.getSyncOrNull(userWalletId)?.mapNotNull {
if (it.network in networks) {
it.copy(value = NetworkStatus.Refreshing)
} else {
null
}
}
if (statusesToRefresh != null) {
networksStatusesStore.storeAll(key = userWalletId, values = statusesToRefresh.toSet())
}
networksStatusesStore.refresh(key = userWalletId, networks = networks)
}
val currencies = getCurrencies(userWalletId, networks)

View file

@ -100,6 +100,10 @@ internal class DefaultQuotesRepository(
// it changes after filterExpiredCurrenciesIds
// calls with different coroutines and lead to fetchQuotes
mutex.withLock {
if (refresh) {
quotesStore.refresh(currenciesIds)
}
val expiredCurrenciesIds = filterExpiredCurrenciesIds(
currenciesIds = currenciesIds,
refresh = refresh || quotesFetchedForAppCurrency != appCurrencyId,