From e20e20124e6d3697aa89de587cc2fc2a73f8db2f Mon Sep 17 00:00:00 2001 From: Tangem Date: Wed, 13 Dec 2023 10:56:08 +0300 Subject: [PATCH] Updated on 2026-08-14 --- .../presentation/wallet/loaders/WalletLoaderStorage.kt | 5 +++++ .../wallet/loaders/WalletScreenContentLoader.kt | 5 +++++ .../presentation/wallet/viewmodels/WalletViewModelV2.kt | 6 ++++++ .../wallet/viewmodels/WalletsUpdateActionResolverV2.kt | 2 +- 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/loaders/WalletLoaderStorage.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/loaders/WalletLoaderStorage.kt index 11414466c8..069a7865eb 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/loaders/WalletLoaderStorage.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/loaders/WalletLoaderStorage.kt @@ -23,4 +23,9 @@ internal class WalletLoaderStorage @Inject constructor() { loaders.remove(id) } } + + fun clear() { + loaders.values.forEach { it.forEach(Job::cancel) } + loaders.clear() + } } \ No newline at end of file diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/loaders/WalletScreenContentLoader.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/loaders/WalletScreenContentLoader.kt index 24b6e550ed..96d4175d6b 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/loaders/WalletScreenContentLoader.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/loaders/WalletScreenContentLoader.kt @@ -63,6 +63,11 @@ internal class WalletScreenContentLoader @Inject constructor( storage.remove(id) } + fun cancelAll() { + Timber.d("All content loading is canceled") + storage.clear() + } + private fun loadInternal( userWallet: UserWallet, appCurrency: AppCurrency, diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/WalletViewModelV2.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/WalletViewModelV2.kt index 1a53f4955c..d4051c9756 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/WalletViewModelV2.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/WalletViewModelV2.kt @@ -80,6 +80,12 @@ internal class WalletViewModelV2 @Inject constructor( clickIntents.initialize(router, viewModelScope) } + override fun onCleared() { + super.onCleared() + stateHolder.clear() + walletScreenContentLoader.cancelAll() + } + private fun suggestToEnableBiometrics() { viewModelScope.launch(dispatchers.main) { withContext(dispatchers.io) { delay(timeMillis = 1_800) } diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/WalletsUpdateActionResolverV2.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/WalletsUpdateActionResolverV2.kt index 595c2987be..e1f8088ebe 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/WalletsUpdateActionResolverV2.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/WalletsUpdateActionResolverV2.kt @@ -228,7 +228,7 @@ internal class WalletsUpdateActionResolverV2 @Inject constructor( data class ReinitializeWallets(val selectedWallet: UserWallet) : Action() { override fun toString(): String { - return "Reinitialize(selectedWallet = ${selectedWallet.walletId})" + return "ReinitializeWallets(selectedWallet = ${selectedWallet.walletId})" } }