Updated on 2026-08-14

This commit is contained in:
Tangem 2026-07-10 05:08:58 -07:00
parent b1cfd6ff50
commit f536fe0844

View file

@ -146,38 +146,14 @@ internal class DefaultSingleAccountStatusListProducer @AssistedInject constructo
flattenCurrency = flattenCurrency,
)
val accounts = accountListFlow.value.accounts
val hasPaymentAccount = accounts.any { it is Account.Payment }
val hasVirtualAccount = accounts.any { it is Account.Virtual }
logger.i("flattenFlow[$walletId]: payment=$hasPaymentAccount, virtual=$hasVirtualAccount")
val specialStatusFlows = buildList<Flow<AccountStatus>> {
if (hasPaymentAccount) {
add(
paymentAccountStatusSupplier.invoke(userWalletId = walletId)
.onEach { status ->
logger.i(
"flattenFlow[$walletId]: paymentAccountStatus emitted " +
"valueType=${status.value::class.simpleName}",
val specialStatusesFlow: Flow<Map<AccountId, AccountStatus>> = combine(
paymentAccountStatusSupplier.invoke(userWalletId = walletId),
virtualAccountStatusSupplier.invoke(userWalletId = walletId),
) { paymentStatus, virtualStatus ->
mapOf(
paymentStatus.accountId to paymentStatus,
virtualStatus.accountId to virtualStatus,
)
},
)
}
if (hasVirtualAccount) {
add(
virtualAccountStatusSupplier.invoke(userWalletId = walletId)
.onEach { status ->
logger.i(
"flattenFlow[$walletId]: virtualAccountStatus emitted " +
"valueType=${status.value::class.simpleName}",
)
},
)
}
}
val specialStatusesFlow: Flow<Map<AccountId, AccountStatus>> = if (specialStatusFlows.isEmpty()) {
flowOf(emptyMap())
} else {
combine(specialStatusFlows) { statuses -> statuses.associateBy(AccountStatus::accountId) }
}
combine(