From 20d40e18613feafe472992819ba1ec4aaf5aa6da Mon Sep 17 00:00:00 2001 From: Tangem Date: Wed, 14 Aug 2024 16:57:02 +0400 Subject: [PATCH] Updated on 2026-08-14 --- .../viewmodels/TokensListMigration.kt | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/tangem/tap/features/tokens/impl/presentation/viewmodels/TokensListMigration.kt b/app/src/main/java/com/tangem/tap/features/tokens/impl/presentation/viewmodels/TokensListMigration.kt index 41495924b3..ac028fde72 100644 --- a/app/src/main/java/com/tangem/tap/features/tokens/impl/presentation/viewmodels/TokensListMigration.kt +++ b/app/src/main/java/com/tangem/tap/features/tokens/impl/presentation/viewmodels/TokensListMigration.kt @@ -4,7 +4,6 @@ import arrow.core.Either import com.tangem.blockchain.common.Blockchain import com.tangem.blockchain.common.Token import com.tangem.common.routing.AppRoute -import com.tangem.common.routing.utils.popTo import com.tangem.data.tokens.utils.CryptoCurrencyFactory import com.tangem.domain.card.DerivePublicKeysUseCase import com.tangem.domain.common.util.derivationStyleProvider @@ -126,7 +125,7 @@ internal class TokensListMigration( val isNothingToDoWithBlockchain = blockchainsToAdd.isEmpty() && blockchainsToRemove.isEmpty() if (isNothingToDoWithTokens && isNothingToDoWithBlockchain) { store.dispatchDebugErrorNotification(message = "Nothing to save") - store.dispatchNavigationAction { popTo() } + navigateToWallet() return } @@ -135,11 +134,23 @@ internal class TokensListMigration( derivePublicKeysUseCase(userWalletId = currentUserWallet.walletId, currencies = currencyList) .onRight { addCryptoCurrenciesUseCase(userWalletId = currentUserWallet.walletId, currencies = currencyList) - store.dispatchNavigationAction { popTo() } + navigateToWallet() } .onLeft { Timber.e(it, "Failed to derive public keys") } } + private fun navigateToWallet() { + store.dispatchNavigationAction { + val route = AppRoute.Wallet + + if (route in stack) { + popTo(route) + } else { + replaceAll(route) + } + } + } + private suspend fun removeCurrenciesIfNeeded(userWalletId: UserWalletId, currencies: List) { if (currencies.isEmpty()) return val currenciesRepository = store.inject(DaggerGraphState::currenciesRepository)