Updated on 2026-08-14

This commit is contained in:
Tangem 2023-05-05 23:38:49 +03:00
parent 87e506a9e7
commit 438aecc167
8 changed files with 53 additions and 19 deletions

View file

@ -57,4 +57,6 @@ internal sealed interface WalletSelectorAction : Action {
) : WalletSelectorAction
object CloseError : WalletSelectorAction
object ClearUserWallets : WalletSelectorAction
}

View file

@ -7,8 +7,8 @@ import com.tangem.common.doOnSuccess
import com.tangem.common.flatMap
import com.tangem.common.map
import com.tangem.core.analytics.Analytics
import com.tangem.domain.models.scan.ScanResponse
import com.tangem.domain.common.util.UserWalletId
import com.tangem.domain.models.scan.ScanResponse
import com.tangem.tap.common.analytics.events.AnalyticsParam
import com.tangem.tap.common.analytics.events.Basic
import com.tangem.tap.common.analytics.events.MyWallets
@ -81,6 +81,12 @@ internal class WalletSelectorMiddleware {
is WalletSelectorAction.ChangeAppCurrency -> {
refreshUserWalletsAmounts()
}
is WalletSelectorAction.ClearUserWallets -> scope.launch {
clearUserWallets()
.doOnFailure { e ->
Timber.e(e, "Unable to clear user wallets")
}
}
is WalletSelectorAction.AddWallet.Success,
is WalletSelectorAction.AddWallet.Error,
is WalletSelectorAction.SelectedWalletChanged,

View file

@ -59,6 +59,7 @@ internal object WalletSelectorReducer {
is WalletSelectorAction.SelectWallet,
is WalletSelectorAction.RemoveWallets,
is WalletSelectorAction.RenameWallet,
is WalletSelectorAction.ClearUserWallets,
-> state
}
}

View file

@ -200,13 +200,17 @@ internal class WalletSelectorViewModel : ViewModel(), StoreSubscriber<WalletSele
onDismiss = this::dismissWarningDialog,
)
is UserWalletsListError.BiometricsAuthenticationDisabled -> WarningModel.BiometricsDisabledWarning(
onConfirm = { /* [REDACTED_TODO_COMMENT] */ },
onConfirm = this::clearUserWallets,
onDismiss = this::dismissWarningDialog,
)
else -> currentDialog
}
}
private fun clearUserWallets() {
store.dispatch(WalletSelectorAction.ClearUserWallets)
}
private fun dismissWarningDialog() {
stateInternal.update { prevState ->
prevState.copy(

View file

@ -18,4 +18,6 @@ internal sealed interface WelcomeAction : Action {
data class HandleIntentIfNeeded(val intent: Intent?) : WelcomeAction
object CloseError : WelcomeAction
object ClearUserWallets : WelcomeAction
}

View file

@ -3,11 +3,14 @@ package com.tangem.tap.features.welcome.redux
import android.content.Intent
import com.tangem.common.core.TangemSdkError
import com.tangem.common.doOnFailure
import com.tangem.common.doOnResult
import com.tangem.common.doOnSuccess
import com.tangem.common.flatMap
import com.tangem.domain.models.scan.ScanResponse
import com.tangem.tap.common.analytics.events.AnalyticsParam
import com.tangem.tap.common.analytics.events.Basic
import com.tangem.tap.common.extensions.dispatchOnMain
import com.tangem.tap.common.extensions.dispatchWithMain
import com.tangem.tap.common.extensions.onUserWalletSelected
import com.tangem.tap.common.redux.AppState
import com.tangem.tap.common.redux.navigation.AppScreen
@ -51,6 +54,9 @@ internal class WelcomeMiddleware {
is WelcomeAction.HandleIntentIfNeeded -> {
handleInitialIntent(action.intent)
}
is WelcomeAction.ClearUserWallets -> {
clearUserWallets()
}
is WelcomeAction.ProceedWithBiometrics.Error,
is WelcomeAction.ProceedWithCard.Error,
is WelcomeAction.ProceedWithBiometrics.Success,
@ -60,22 +66,31 @@ internal class WelcomeMiddleware {
}
}
private fun proceedWithBiometrics(state: WelcomeState) {
scope.launch {
userWalletsListManager.unlockIfLockable()
.doOnFailure { error ->
Timber.e(error, "Unable to unlock user wallets with biometrics")
store.dispatchOnMain(WelcomeAction.ProceedWithBiometrics.Error(error))
}
.doOnSuccess { selectedUserWallet ->
store.dispatchOnMain(SignInAction.SetSignInType(Basic.SignedIn.SignInType.Biometric))
store.dispatchOnMain(NavigationAction.NavigateTo(AppScreen.Wallet))
store.dispatchOnMain(WelcomeAction.ProceedWithBiometrics.Success)
store.onUserWalletSelected(userWallet = selectedUserWallet)
private fun clearUserWallets() = scope.launch {
userWalletsListManager.clear()
.flatMap { tangemSdkManager.clearSavedUserCodes() }
.doOnFailure { e ->
Timber.e(e, "Unable to clear user wallets")
}
.doOnResult {
store.dispatchWithMain(NavigationAction.PopBackTo(AppScreen.Home))
}
}
intentHandler.handleWalletConnectLink(state.intent)
}
}
private fun proceedWithBiometrics(state: WelcomeState) = scope.launch {
userWalletsListManager.unlockIfLockable()
.doOnFailure { error ->
Timber.e(error, "Unable to unlock user wallets with biometrics")
store.dispatchOnMain(WelcomeAction.ProceedWithBiometrics.Error(error))
}
.doOnSuccess { selectedUserWallet ->
store.dispatchOnMain(SignInAction.SetSignInType(Basic.SignedIn.SignInType.Biometric))
store.dispatchOnMain(NavigationAction.NavigateTo(AppScreen.Wallet))
store.dispatchOnMain(WelcomeAction.ProceedWithBiometrics.Success)
store.onUserWalletSelected(userWallet = selectedUserWallet)
intentHandler.handleWalletConnectLink(state.intent)
}
}
private fun proceedWithCard(state: WelcomeState) = scope.launch {

View file

@ -72,7 +72,7 @@ internal class WelcomeViewModel : ViewModel(), StoreSubscriber<WelcomeState> {
onDismiss = this::dismissWarning,
)
is UserWalletsListError.BiometricsAuthenticationDisabled -> WarningModel.BiometricsDisabledWarning(
onConfirm = { /* [REDACTED_TODO_COMMENT] */ },
onConfirm = this::clearUserWallets,
onDismiss = this::dismissWarning,
)
else -> null
@ -88,6 +88,10 @@ internal class WelcomeViewModel : ViewModel(), StoreSubscriber<WelcomeState> {
closeError()
}
private fun clearUserWallets() {
store.dispatch(WelcomeAction.ClearUserWallets)
}
private fun subscribeToStoreChanges() {
store.subscribe(this) { appState ->
appState.skip { old, new -> old.welcomeState == new.welcomeState }

View file

@ -27,7 +27,7 @@
<string name="biometric_lockout_permanent_warning_description">Please scan the card</string>
<string name="biometric_lockout_warning_description">Please try again in 30 seconds or scan the card</string>
<string name="biometric_lockout_warning_title">Too many attempts</string>
<string name="biometric_unavailable_warning">You have disabled biometric authentication on your phone and will not be able to save wallets in the app. To save wallets, please enable the biometric authentication function in your phone settings.</string> <string name="biometric_unavailable_warning">You have disabled biometric authentication on your phone and will not be able to save wallets in the app. To save wallets, please enable the biometric authentication function in your phone settings.</string>
<string name="biometric_unavailable_warning">You have disabled biometric authentication on your phone and will not be able to save wallets in the app. To save wallets, please enable the biometric authentication function in your phone settings.</string>
<string name="card_settings_access_code_recovery_disabled_description">Disable this option if you don\'t want this card to be used to reset access codes on other cards of this wallet. Note that you will not be able to reset access code on this card as well.</string>
<string name="card_settings_access_code_recovery_enabled_description">Allows you to use this card to reset access code on other cards in this wallet</string>
<string name="card_settings_access_code_recovery_footer">Disable the ability to reset access code on this card or other cards in this wallet</string>