Updated on 2026-08-14

This commit is contained in:
Tangem 2023-10-06 18:16:45 +03:00
parent 59080b682d
commit 8c3972bc43

View file

@ -914,8 +914,26 @@ internal class WalletViewModel @Inject constructor(
private fun getSingleCurrencyContent(index: Int) {
val wallet = getWallet(index)
updatePrimaryCurrencyStatus(userWalletId = wallet.walletId)
updateNotifications(index)
getPrimaryCurrencyStatusUpdatesUseCase(userWalletId = wallet.walletId)
.distinctUntilChanged()
.onEach { maybeCryptoCurrencyStatus ->
uiState = stateFactory.getSingleCurrencyLoadedBalanceState(maybeCryptoCurrencyStatus)
maybeCryptoCurrencyStatus.onRight { status ->
singleWalletCryptoCurrencyStatus = status
if (status.value.amount?.isZero() == false) {
setWalletWithFundsFoundUseCase()
}
updateNotifications(index)
updateButtons(userWalletId = wallet.walletId, currencyStatus = status)
updateTxHistory(status.currency)
}
}
.flowOn(dispatchers.io)
.launchIn(viewModelScope)
.saveIn(marketPriceJobHolder)
}
private fun updateTxHistory(currency: CryptoCurrency) {
@ -936,28 +954,6 @@ internal class WalletViewModel @Inject constructor(
}
}
private fun updatePrimaryCurrencyStatus(userWalletId: UserWalletId) {
getPrimaryCurrencyStatusUpdatesUseCase(userWalletId = userWalletId)
.distinctUntilChanged()
.onEach { maybeCryptoCurrencyStatus ->
uiState = stateFactory.getSingleCurrencyLoadedBalanceState(maybeCryptoCurrencyStatus)
maybeCryptoCurrencyStatus.onRight { status ->
singleWalletCryptoCurrencyStatus = status
if (status.value.amount?.isZero() == false) {
setWalletWithFundsFoundUseCase()
}
updateButtons(userWalletId = userWalletId, currencyStatus = status)
updateTxHistory(status.currency)
}
}
.flowOn(dispatchers.io)
.launchIn(viewModelScope)
.saveIn(marketPriceJobHolder)
}
private fun updateButtons(userWalletId: UserWalletId, currencyStatus: CryptoCurrencyStatus) {
getCryptoCurrencyActionsUseCase(userWalletId = userWalletId, cryptoCurrencyStatus = currencyStatus)
.distinctUntilChanged()