Updated on 2026-08-14

This commit is contained in:
Tangem 2025-02-24 10:39:12 +04:00
parent 2286db21d0
commit a9bbf96bd1
4 changed files with 19 additions and 16 deletions

View file

@ -7,6 +7,7 @@ import com.tangem.datasource.local.quote.converter.QuoteConverter
import com.tangem.domain.models.StatusSource
import com.tangem.domain.tokens.model.CryptoCurrency
import com.tangem.domain.tokens.model.Quote
import com.tangem.utils.extensions.addOrReplace
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.flow.*
import kotlinx.coroutines.launch
@ -110,7 +111,7 @@ internal class DefaultQuotesStore(
private suspend fun storeInRuntimeStore(values: Set<Quote>) {
runtimeStore.update(default = emptySet()) { saved ->
(saved + values).distinctBy { it.rawCurrencyId }.toSet()
saved.addOrReplace(items = values) { prev, new -> prev.rawCurrencyId == new.rawCurrencyId }
}
}

View file

@ -52,14 +52,14 @@ class FetchTokenListUseCase(
coroutineScope {
val fetchStatuses = async {
fetchNetworksStatuses(
userWalletId,
currencies.mapTo(hashSetOf()) { it.network },
userWalletId = userWalletId,
networks = currencies.mapTo(hashSetOf()) { it.network },
refresh = mode.refreshNetworksStatuses,
)
}
val fetchQuotes = async {
fetchQuotes(
currencies.mapTo(hashSetOf()) { it.id },
currenciesIds = currencies.mapTo(hashSetOf()) { it.id },
refresh = mode.refreshQuotes,
)
}

View file

@ -10,6 +10,7 @@ import com.tangem.domain.tokens.error.TokenListError
import com.tangem.domain.tokens.model.CryptoCurrency
import com.tangem.domain.tokens.model.CryptoCurrencyStatus
import com.tangem.domain.tokens.model.TokenList
import com.tangem.domain.tokens.model.TotalFiatBalance
import com.tangem.domain.wallets.models.SeedPhraseNotificationsStatus
import com.tangem.domain.wallets.models.UserWallet
import com.tangem.domain.wallets.usecase.IsNeedToBackupUseCase
@ -68,17 +69,18 @@ internal class GetMultiWalletWarningsFactory @Inject constructor(
private fun MutableList<WalletNotification>.addUsedOutdatedDataNotification(
maybeTokenList: Lce<TokenListError, TokenList>,
) {
val tokenList = maybeTokenList.getOrNull(isPartialContentAccepted = false)?.flattenCurrencies().orEmpty()
val hasOnlyCachedData = tokenList.any {
when (val value = it.value) {
is CryptoCurrencyStatus.Loaded -> value.source == StatusSource.ONLY_CACHE
is CryptoCurrencyStatus.NoAccount -> value.source == StatusSource.ONLY_CACHE
else -> false
}
}
addIf(element = WalletNotification.UsedOutdatedData, condition = hasOnlyCachedData)
addIf(
element = WalletNotification.UsedOutdatedData,
condition = maybeTokenList.fold(
ifLoading = {
(it?.totalFiatBalance as? TotalFiatBalance.Loaded)?.source == StatusSource.ONLY_CACHE
},
ifContent = {
(it.totalFiatBalance as? TotalFiatBalance.Loaded)?.source == StatusSource.ONLY_CACHE
},
ifError = { false },
),
)
}
private fun MutableList<WalletNotification>.addCriticalNotifications(

View file

@ -122,7 +122,7 @@ internal class WalletClickIntents @Inject constructor(
SetRefreshStateTransformer(userWalletId = userWallet.walletId, isRefreshing = showRefreshState),
)
viewModelScope.launch(dispatchers.main) {
viewModelScope.launch {
val maybeFetchResult = if (userWallet.scanResponse.cardTypesResolver.isSingleWalletWithToken()) {
fetchCardTokenListUseCase(userWalletId = userWallet.walletId, refresh = true)
} else {