diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/WalletViewModel.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/WalletViewModel.kt index 0705092df8..e860f3d518 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/WalletViewModel.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/WalletViewModel.kt @@ -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()