Updated on 2026-08-14

This commit is contained in:
Tangem 2025-02-10 17:24:38 +03:00
parent cd846f1092
commit 978ad99625
2 changed files with 10 additions and 1 deletions

View file

@ -40,6 +40,7 @@ dependencies {
/** Android - Other */
implementation(deps.androidx.paging.runtime)
implementation(deps.timber)
/** Utils */
implementation(deps.jodatime)

View file

@ -21,6 +21,7 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.transformLatest
import timber.log.Timber
class GetWalletTotalBalanceUseCase(
private val currenciesRepository: CurrenciesRepository,
@ -42,7 +43,14 @@ class GetWalletTotalBalanceUseCase(
return combine(flows) { balances ->
lce {
balances.fold(mutableMapOf()) { acc, (userWalletId, maybeBalance) ->
val balance = maybeBalance.bindOrNull() ?: TotalFiatBalance.Loading
val balance = maybeBalance.fold(
ifLoading = { TotalFiatBalance.Loading },
ifContent = { it },
ifError = {
Timber.e("failed to load balances with error: $it")
TotalFiatBalance.Failed
},
)
isLoading.update { it || balance is TotalFiatBalance.Loading }