Updated on 2026-08-14

This commit is contained in:
Tangem 2022-12-14 10:33:15 +03:00
commit 6baf8bd3f1
5 changed files with 29 additions and 18 deletions

View file

@ -143,10 +143,6 @@ internal class BiometricUserWalletsListManager(
}
override suspend fun delete(walletIds: List<UserWalletId>): CompletionResult<Unit> {
if (state.value.isLocked) {
return CompletionResult.Success(Unit)
}
val walletIdsToRemove = state.value.wallets
.map { it.walletId }
.filter { it in walletIds }

View file

@ -121,8 +121,12 @@ class DetailsMiddleware {
val selectedUserWallet = userWalletsListManager.selectedUserWalletSync
if (selectedUserWallet != null) {
store.dispatchOnMain(NavigationAction.PopBackTo(AppScreen.Wallet))
store.onUserWalletSelected(selectedUserWallet)
if (userWalletsListManager.isLockedSync) {
store.dispatchOnMain(NavigationAction.PopBackTo(AppScreen.Welcome))
} else {
store.dispatchOnMain(NavigationAction.PopBackTo(AppScreen.Wallet))
store.onUserWalletSelected(selectedUserWallet)
}
} else {
userWalletsListManager.lock()
store.dispatchOnMain(NavigationAction.PopBackTo(AppScreen.Home))

View file

@ -1,16 +1,20 @@
package com.tangem.tap.features.onboarding
import com.tangem.common.doOnSuccess
import com.tangem.domain.common.ProductType
import com.tangem.domain.common.ScanResponse
import com.tangem.tap.common.extensions.dispatchOnMain
import com.tangem.tap.common.extensions.onCardScanned
import com.tangem.tap.common.extensions.onUserWalletSelected
import com.tangem.tap.common.redux.navigation.AppScreen
import com.tangem.tap.common.redux.navigation.NavigationAction
import com.tangem.tap.domain.model.builders.UserWalletBuilder
import com.tangem.tap.features.saveWallet.redux.SaveWalletAction
import com.tangem.tap.preferencesStorage
import com.tangem.tap.scope
import com.tangem.tap.store
import com.tangem.tap.tangemSdkManager
import com.tangem.tap.userWalletsListManager
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
@ -55,6 +59,18 @@ class OnboardingHelper {
backupCardsIds: List<String>? = null,
) {
when {
// When should save user wallets but manager is locked, then unlock manager with card
preferencesStorage.shouldSaveUserWallets &&
userWalletsListManager.isLockedSync -> scope.launch {
val userWallet = UserWalletBuilder(scanResponse).build()
tangemSdkManager.setAccessCodeRequestPolicy(useBiometricsForAccessCode = false)
userWalletsListManager.unlockWithCard(userWallet)
.doOnSuccess {
store.onUserWalletSelected(userWallet)
}
}
// When should save user wallets, then save card without navigate to save wallet screen
preferencesStorage.shouldSaveUserWallets -> scope.launch {
store.dispatchOnMain(
SaveWalletAction.ProvideBackupInfo(
@ -65,6 +81,8 @@ class OnboardingHelper {
)
store.dispatchOnMain(SaveWalletAction.Save)
}
// When should not save user wallets but device has biometry and save wallet screen has not been shown,
// then open save wallet screen
tangemSdkManager.canUseBiometry &&
preferencesStorage.shouldShowSaveUserWalletScreen -> scope.launch {
delay(timeMillis = 1_200)
@ -77,6 +95,7 @@ class OnboardingHelper {
)
store.dispatchOnMain(NavigationAction.NavigateTo(AppScreen.SaveWallet))
}
// If device has no biometry and save wallet screen has been shown, then go through old scenario
else -> scope.launch {
store.onCardScanned(scanResponse)
}

View file

@ -94,6 +94,7 @@ internal class SaveWalletMiddleware {
saveAccessCodeIfNeeded(state.backupInfo?.accessCode, userWallet.cardsInWallet)
.flatMap { userWalletsListManager.save(userWallet, canOverride = true) }
.flatMap { userWalletsListManager.selectWallet(userWallet.walletId) }
.doOnFailure { error ->
store.dispatchOnMain(SaveWalletAction.Save.Error(error))
}
@ -110,17 +111,10 @@ internal class SaveWalletMiddleware {
userWallet.hasAccessCode,
)
val isSavedWalletSelected =
userWalletsListManager.selectedUserWalletSync?.walletId == userWallet.walletId
store.dispatchOnMain(SaveWalletAction.Save.Success)
if (isSavedWalletSelected) {
store.dispatchOnMain(NavigationAction.PopBackTo(AppScreen.Wallet))
store.onUserWalletSelected(userWallet)
} else {
store.dispatchOnMain(NavigationAction.NavigateTo(AppScreen.WalletSelector))
}
store.dispatchOnMain(NavigationAction.PopBackTo(AppScreen.Wallet))
store.onUserWalletSelected(userWallet)
}
}
}

View file

@ -78,14 +78,12 @@ internal class WelcomeMiddleware {
scanCardInternal { scanResponse ->
val userWallet = UserWalletBuilder(scanResponse).build()
tangemSdkManager.setAccessCodeRequestPolicy(useBiometricsForAccessCode = false)
userWalletsListManager.unlockWithCard(userWallet)
.doOnFailure { error ->
store.dispatchOnMain(WelcomeAction.ProceedWithCard.Error(error))
}
.doOnSuccess {
tangemSdkManager.setAccessCodeRequestPolicy(
useBiometricsForAccessCode = false,
)
store.dispatchOnMain(NavigationAction.NavigateTo(AppScreen.Wallet))
store.dispatchOnMain(WelcomeAction.ProceedWithCard.Success)
store.onUserWalletSelected(userWallet)