Updated on 2026-08-14

This commit is contained in:
Tangem 2026-02-04 16:57:30 +03:00
parent d86b3784b3
commit 52e7b5e58c
3 changed files with 5 additions and 4 deletions

View file

@ -15,7 +15,7 @@ import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.flow.mapNotNull
import kotlinx.coroutines.flow.map
import timber.log.Timber
/**
@ -44,7 +44,7 @@ internal class DefaultSingleStakingBalanceProducer @AssistedInject constructor(
return multiStakingBalanceSupplier(
params = MultiStakingBalanceProducer.Params(userWalletId = params.userWalletId),
)
.mapNotNull { balances ->
.map { balances ->
val currentStakingId = params.stakingId
val currentBalances = balances.filter { it.stakingId == currentStakingId }
@ -53,7 +53,7 @@ internal class DefaultSingleStakingBalanceProducer @AssistedInject constructor(
currentStakingId = currentStakingId,
currentBalances = currentBalances,
analyticsExceptionHandler = analyticsExceptionHandler,
)
) ?: StakingBalance.Error(stakingId = currentStakingId)
}
.flowOn(dispatchers.default)
}

View file

@ -200,7 +200,7 @@ internal class DefaultSingleStakingBalanceProducerTest {
val actual = getEmittedValues(flow = producerFlow)
// Assert
Truth.assertThat(actual).isEmpty()
Truth.assertThat(actual).containsExactly(StakingBalance.Error(stakingId = tonId))
verify(exactly = 1) { multiNetworkStatusSupplier(multiParams) }
}

View file

@ -78,6 +78,7 @@ internal class DefaultPortfolioFetcher @AssistedInject constructor(
}
private fun balancesForWallets(wallets: List<UserWallet>): Flow<Map<UserWalletId, PortfolioBalance>> {
if (wallets.isEmpty()) return flowOf(emptyMap())
val balanceFlows = wallets.map { walletAccountsBalancesFlow(it) }
return combine(balanceFlows) { pairs -> pairs.toMap() }
}