From 35a6f43bf31ae84ee4b316b61b9e43baea7c4e4c Mon Sep 17 00:00:00 2001 From: Tangem Date: Mon, 17 Nov 2025 12:33:30 +0500 Subject: [PATCH] Updated on 2026-08-14 --- .../intents/WalletWarningsClickIntents.kt | 37 ++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/intents/WalletWarningsClickIntents.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/intents/WalletWarningsClickIntents.kt index 945d0dff0c..ff0397e424 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/intents/WalletWarningsClickIntents.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/intents/WalletWarningsClickIntents.kt @@ -11,10 +11,15 @@ import com.tangem.core.decompose.di.ModelScoped import com.tangem.core.decompose.ui.UiMessageSender import com.tangem.core.navigation.url.UrlOpener import com.tangem.core.ui.components.bottomsheets.message.* +import com.tangem.core.ui.extensions.TextReference import com.tangem.core.ui.extensions.resourceReference +import com.tangem.core.ui.message.DialogMessage +import com.tangem.core.ui.message.DialogMessage.Companion.invoke +import com.tangem.core.ui.message.SnackbarMessage import com.tangem.core.ui.message.bottomSheetMessage import com.tangem.domain.card.SetCardWasScannedUseCase import com.tangem.domain.common.wallets.UserWalletsListRepository +import com.tangem.domain.common.wallets.error.UnlockWalletError import com.tangem.domain.feedback.GetWalletMetaInfoUseCase import com.tangem.domain.feedback.SendFeedbackEmailUseCase import com.tangem.domain.feedback.models.FeedbackEmailType @@ -139,6 +144,7 @@ internal class WalletWarningsClickIntentsImplementor @Inject constructor( private val messageSender: UiMessageSender, private val setNotificationsEnabledUseCase: SetNotificationsEnabledUseCase, private val getWalletsListForEnablingUseCase: GetWalletsForAutomaticallyPushEnablingUseCase, + private val uiMessageSender: UiMessageSender, ) : BaseWalletClickIntents(), WalletWarningsClickIntents { private val finalizeWalletSetupAlertBS @@ -221,11 +227,40 @@ internal class WalletWarningsClickIntentsImplementor @Inject constructor( userWalletsListRepository.unlockAllWallets() .onLeft { val selectedUserWallet = getSelectedUserWallet() ?: return@onLeft + val selectedUserWalletId = selectedUserWallet.walletId val method = when (selectedUserWallet) { is UserWallet.Cold -> UserWalletsListRepository.UnlockMethod.Scan() is UserWallet.Hot -> UserWalletsListRepository.UnlockMethod.AccessCode } - userWalletsListRepository.unlock(stateHolder.getSelectedWalletId(), method) + userWalletsListRepository + .unlock(stateHolder.getSelectedWalletId(), method) + .onLeft { + when (it) { + UnlockWalletError.AlreadyUnlocked -> Unit + UnlockWalletError.ScannedCardWalletNotMatched -> { + uiMessageSender.send( + message = DialogMessage( + title = resourceReference(R.string.common_warning), + message = resourceReference(R.string.error_wrong_wallet_tapped), + ), + ) + } + UnlockWalletError.UnableToUnlock -> { + Timber.e("Unable to unlock wallet with id: $selectedUserWalletId") + uiMessageSender.send( + SnackbarMessage(TextReference.Res(R.string.generic_error)), + ) + } + UnlockWalletError.UserCancelled -> Unit + UnlockWalletError.UserWalletNotFound -> { + // This should never happen in this flow + Timber.e("User wallet not found for unlock: $selectedUserWalletId") + uiMessageSender.send( + SnackbarMessage(TextReference.Res(R.string.generic_error)), + ) + } + } + } } } return