diff --git a/features/welcome/impl/src/main/kotlin/com/tangem/features/welcome/impl/model/WelcomeModel.kt b/features/welcome/impl/src/main/kotlin/com/tangem/features/welcome/impl/model/WelcomeModel.kt index 27d08db855..3b301a83a1 100644 --- a/features/welcome/impl/src/main/kotlin/com/tangem/features/welcome/impl/model/WelcomeModel.kt +++ b/features/welcome/impl/src/main/kotlin/com/tangem/features/welcome/impl/model/WelcomeModel.kt @@ -91,7 +91,10 @@ internal class WelcomeModel @Inject constructor( router.replaceAll(AppRoute.Wallet) } .onLeft { - it.handle(null, onUserCancelled = { tryToUnlockWithAccessCodeRightAway() }) + it.handle( + specificWalletId = null, + onUserCancelled = { tryToUnlockWithAccessCodeRightAway() }, + ) setSelectWalletState() } } else { @@ -103,10 +106,10 @@ internal class WelcomeModel @Inject constructor( private suspend fun tryToUnlockWithAccessCodeRightAway() { if (onlyOneHotWalletWithAccessCode()) { - val userWallets = userWalletsListRepository.userWalletsSync() - val userWallet = userWallets.first() + val hotWalletLockedWithAccessCode = userWalletsListRepository.userWalletsSync() + .first { it.isLocked && it is UserWallet.Hot } as UserWallet.Hot uiState.value = WelcomeUM.Empty - unlockWallet(userWallet.walletId, UserWalletsListRepository.UnlockMethod.AccessCode) + unlockWallet(hotWalletLockedWithAccessCode.walletId, UserWalletsListRepository.UnlockMethod.AccessCode) } } @@ -144,7 +147,7 @@ internal class WelcomeModel @Inject constructor( } private suspend fun onlyOneHotWalletWithAccessCode(): Boolean { - val userWalletsWithLock = userWalletsListRepository.userWalletsSync().filter { it.isLocked } + val userWalletsWithLock = userWalletsListRepository.userWalletsSync() if (userWalletsWithLock.size != 1) return false val wallet = userWalletsWithLock.first() return wallet is UserWallet.Hot && wallet.hotWalletId.authType != HotWalletId.AuthType.NoPassword