From 30a7d0dcecd4cf29220e16e25b966f851562e8d3 Mon Sep 17 00:00:00 2001 From: Tangem Date: Thu, 21 Aug 2025 18:27:08 +0400 Subject: [PATCH] Updated on 2026-08-14 --- .../CachedCurrenciesStatusesOperations.kt | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/operations/CachedCurrenciesStatusesOperations.kt b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/operations/CachedCurrenciesStatusesOperations.kt index c82e831875..70700beea8 100644 --- a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/operations/CachedCurrenciesStatusesOperations.kt +++ b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/operations/CachedCurrenciesStatusesOperations.kt @@ -168,15 +168,18 @@ class CachedCurrenciesStatusesOperations( combine( flow = getQuotes(currenciesIds), flow2 = networksStatusesUpdates, - flow3 = networksStatusesUpdates.flatMapLatest { - val currenciesAddresses = it.getOrElse(default = { emptySet() }) - .mapNotNull { - val currency = currencies.firstOrNull { currency -> currency.network == it.network } - ?: return@mapNotNull null + flow3 = networksStatusesUpdates.flatMapLatest { maybeNetworksStatuses -> + val networksStatuses = maybeNetworksStatuses.getOrNull() - currency.id to extractAddress(it) + val currenciesAddresses = if (networksStatuses == null) { + emptyMap() + } else { + currencies.associate { currency -> + val networkStatus = networksStatuses.firstOrNull { it.network == currency.network } + + currency.id to extractAddress(networkStatus) } - .toMap() + } getYieldsBalancesUpdates(userWalletId, currenciesAddresses) }, @@ -397,8 +400,11 @@ class CachedCurrenciesStatusesOperations( return channelFlow { val state = MutableStateFlow(emptyList()) - val stakingIds = cryptoCurrencies.mapNotNullTo(hashSetOf()) { - stakingIdFactory.create(currencyId = it.key, defaultAddress = it.value) + val stakingIds = cryptoCurrencies.mapNotNullTo(hashSetOf()) { currencyWithAddress -> + stakingIdFactory.create( + currencyId = currencyWithAddress.key, + defaultAddress = currencyWithAddress.value, + ) .getOrNull() }