From a07ee6d71f576895019cf1fd65b15005a664ce1c Mon Sep 17 00:00:00 2001 From: Tangem Date: Mon, 14 Jul 2025 13:07:15 +0500 Subject: [PATCH] Updated on 2026-08-14 --- .../walletsettings/model/WalletSettingsModel.kt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/model/WalletSettingsModel.kt b/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/model/WalletSettingsModel.kt index b85bb4de06..8861cf7891 100644 --- a/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/model/WalletSettingsModel.kt +++ b/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/model/WalletSettingsModel.kt @@ -24,6 +24,7 @@ import com.tangem.domain.models.scan.ScanResponse import com.tangem.domain.nft.DisableWalletNFTUseCase import com.tangem.domain.nft.EnableWalletNFTUseCase import com.tangem.domain.nft.GetWalletNFTEnabledUseCase +import com.tangem.domain.notifications.GetApplicationIdUseCase import com.tangem.domain.notifications.toggles.NotificationsFeatureToggles import com.tangem.domain.settings.repositories.PermissionRepository import com.tangem.domain.wallets.models.UserWallet @@ -44,6 +45,7 @@ import com.tangem.features.pushnotifications.api.analytics.PushNotificationAnaly import com.tangem.utils.coroutines.CoroutineDispatcherProvider import kotlinx.collections.immutable.PersistentList import kotlinx.collections.immutable.persistentListOf +import kotlinx.coroutines.NonCancellable import kotlinx.coroutines.flow.* import kotlinx.coroutines.launch import timber.log.Timber @@ -72,6 +74,8 @@ internal class WalletSettingsModel @Inject constructor( private val setNotificationsEnabledUseCase: SetNotificationsEnabledUseCase, private val settingsManager: SettingsManager, private val permissionsRepository: PermissionRepository, + private val getApplicationIdUseCase: GetApplicationIdUseCase, + private val associateWalletsWithApplicationIdUseCase: AssociateWalletsWithApplicationIdUseCase, ) : Model() { val params: WalletSettingsComponent.Params = paramsContainer.require() @@ -194,10 +198,20 @@ internal class WalletSettingsModel @Inject constructor( if (hasUserWallets) { router.pop() } else { + clearWalletsAssociatedWithApplicationId() router.replaceAll(AppRoute.Home) } } + private fun clearWalletsAssociatedWithApplicationId() = modelScope.launch(NonCancellable) { + getApplicationIdUseCase().onRight { applicationId -> + associateWalletsWithApplicationIdUseCase(applicationId, emptyList()) + .onLeft { + Timber.e("Unable to associate empty wallets with application ID: $it") + } + } + } + private fun onLinkMoreCardsClick(scanResponse: ScanResponse) { analyticsEventHandler.send(Settings.ButtonCreateBackup) analyticsContextProxy.addContext(scanResponse)