Updated on 2026-08-14

This commit is contained in:
Tangem 2025-11-17 12:33:30 +05:00
parent feb1fb21e8
commit 35a6f43bf3

View file

@ -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