Updated on 2026-08-14

This commit is contained in:
Tangem 2023-03-02 11:24:02 +03:00
commit a09e571828
18 changed files with 240 additions and 62 deletions

View file

@ -20,6 +20,8 @@ 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.domain.model.builders.UserWalletIdBuilder
import com.tangem.tap.domain.userWalletList.isLockedSync
import com.tangem.tap.domain.userWalletList.lockIfLockable
import com.tangem.tap.features.demo.DemoHelper
import com.tangem.tap.features.onboarding.products.twins.redux.CreateTwinWalletMode
import com.tangem.tap.features.onboarding.products.twins.redux.TwinCardsAction
@ -132,7 +134,7 @@ class DetailsMiddleware {
store.onUserWalletSelected(selectedUserWallet)
}
} else {
userWalletsListManager.lock()
userWalletsListManager.lockIfLockable()
store.dispatchOnMain(NavigationAction.PopBackTo(AppScreen.Home))
}
}

View file

@ -26,6 +26,7 @@ import com.tangem.tap.domain.TapError
import com.tangem.tap.domain.extensions.makePrimaryWalletManager
import com.tangem.tap.domain.model.builders.UserWalletIdBuilder
import com.tangem.tap.domain.twins.TwinCardsManager
import com.tangem.tap.domain.userWalletList.isLockedSync
import com.tangem.tap.features.home.RUSSIA_COUNTRY_CODE
import com.tangem.tap.features.onboarding.OnboardingDialog
import com.tangem.tap.features.onboarding.OnboardingHelper
@ -335,7 +336,7 @@ private fun handle(action: Action, dispatch: DispatchFunction) {
}
private fun getPopBackScreen(): AppScreen {
return if (userWalletsListManager.hasSavedUserWallets) {
return if (userWalletsListManager.hasUserWallets) {
if (userWalletsListManager.isLockedSync) {
AppScreen.Welcome
} else {

View file

@ -90,7 +90,7 @@ internal class SaveWalletMiddleware {
.backupCardsIds(state.backupInfo?.backupCardsIds)
.build() ?: return@launch
val isFirstSavedWallet = !userWalletsListManager.hasSavedUserWallets
val isFirstSavedWallet = !userWalletsListManager.hasUserWallets
saveAccessCodeIfNeeded(state.backupInfo?.accessCode, userWallet.cardsInWallet)
.flatMap { userWalletsListManager.save(userWallet, canOverride = true) }

View file

@ -341,7 +341,7 @@ class TokensMiddleware {
private suspend fun removeCurrenciesIfNeeded(currencies: List<Currency>) {
when {
currencies.isEmpty() -> Unit
userWalletsListManager.hasSavedUserWallets -> {
userWalletsListManager.hasUserWallets -> {
walletCurrenciesManager.removeCurrencies(
userWallet = userWalletsListManager.selectedUserWalletSync!!,
currenciesToRemove = currencies,

View file

@ -103,7 +103,7 @@ data class WalletState(
primaryWalletData?.currencyData?.status != BalanceStatus.UnknownBlockchain
val hasSavedWallets: Boolean
get() = userWalletsListManager.hasSavedUserWallets
get() = userWalletsListManager.hasUserWallets
fun getWalletManager(currency: Currency?): WalletManager? {
if (currency?.blockchain == null) return null

View file

@ -377,7 +377,7 @@ class WalletMiddleware {
private fun changeWallet() {
when {
userWalletsListManager.hasSavedUserWallets -> {
userWalletsListManager.hasUserWallets -> {
Analytics.send(MainScreen.ButtonMyWallets())
store.dispatchOnMain(NavigationAction.NavigateTo(AppScreen.WalletSelector))
}

View file

@ -114,7 +114,7 @@ class MultiWalletReducer {
val currency = Currency.fromBlockchainNetwork(action.blockchain, action.token)
val walletManager = state.getWalletManager(currency)
if (walletManager == null) {
val screen = if (userWalletsListManager.hasSavedUserWallets) {
val screen = if (userWalletsListManager.hasUserWallets) {
AppScreen.Welcome
} else {
AppScreen.Home

View file

@ -32,6 +32,7 @@ import com.tangem.tap.common.redux.navigation.NavigationAction
import com.tangem.tap.domain.configurable.warningMessage.WarningMessage
import com.tangem.tap.domain.statePrinter.printScanResponseState
import com.tangem.tap.domain.statePrinter.printWalletState
import com.tangem.tap.domain.userWalletList.lockIfLockable
import com.tangem.tap.features.details.redux.DetailsAction
import com.tangem.tap.features.wallet.redux.ErrorType
import com.tangem.tap.features.wallet.redux.ProgressState
@ -81,13 +82,13 @@ class WalletFragment : Fragment(R.layout.fragment_wallet), StoreSubscriber<Walle
this,
object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
val popBackTo = if (userWalletsListManager.hasSavedUserWallets) {
userWalletsListManager.lock()
userWalletsListManager.lockIfLockable()
val screen = if (userWalletsListManager.hasUserWallets) {
AppScreen.Welcome
} else {
AppScreen.Home
}
store.dispatch(NavigationAction.PopBackTo(popBackTo))
store.dispatch(NavigationAction.PopBackTo(screen))
}
},
)

View file

@ -23,6 +23,7 @@ import com.tangem.tap.domain.model.WalletStoreModel
import com.tangem.tap.domain.model.builders.UserWalletBuilder
import com.tangem.tap.domain.model.builders.UserWalletIdBuilder
import com.tangem.tap.domain.scanCard.ScanCardProcessor
import com.tangem.tap.domain.userWalletList.unlockIfLockable
import com.tangem.tap.features.onboarding.products.wallet.saltPay.message.SaltPayActivationError
import com.tangem.tap.preferencesStorage
import com.tangem.tap.scope
@ -63,7 +64,7 @@ internal class WalletSelectorMiddleware {
updateBalances(action.walletsStores, state)
}
is WalletSelectorAction.UnlockWithBiometry -> {
unlockWalletsWithBiometry()
unlockWallets()
}
is WalletSelectorAction.AddWallet -> {
addWallet()
@ -115,11 +116,11 @@ internal class WalletSelectorMiddleware {
}
}
private fun unlockWalletsWithBiometry() {
private fun unlockWallets() {
Analytics.send(MyWallets.Button.UnlockWithBiometrics())
scope.launch {
userWalletsListManager.unlockWithBiometry()
userWalletsListManager.unlockIfLockable()
.doOnFailure { error ->
Timber.e(error, "Unable to unlock all user wallets")
store.dispatchOnMain(WalletSelectorAction.UnlockWithBiometry.Error(error))
@ -195,7 +196,7 @@ internal class WalletSelectorMiddleware {
if (userWallet.isLocked) {
unlockUserWalletWithScannedCard(userWallet)
} else {
userWalletsListManager.selectWallet(userWalletId)
userWalletsListManager.select(userWalletId)
}
}
.doOnFailure { error ->

View file

@ -8,6 +8,7 @@ import com.tangem.core.analytics.Analytics
import com.tangem.domain.common.util.UserWalletId
import com.tangem.tap.common.analytics.events.MyWallets
import com.tangem.tap.common.extensions.dispatchOnMain
import com.tangem.tap.domain.userWalletList.isLocked
import com.tangem.tap.features.details.ui.cardsettings.TextReference
import com.tangem.tap.features.walletSelector.redux.WalletSelectorAction
import com.tangem.tap.features.walletSelector.redux.WalletSelectorState

View file

@ -17,6 +17,7 @@ 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.domain.scanCard.ScanCardProcessor
import com.tangem.tap.domain.userWalletList.unlockIfLockable
import com.tangem.tap.features.onboarding.products.wallet.saltPay.message.SaltPayActivationError
import com.tangem.tap.intentHandler
import com.tangem.tap.preferencesStorage
@ -66,7 +67,7 @@ internal class WelcomeMiddleware {
private fun proceedWithBiometrics(state: WelcomeState) {
scope.launch {
userWalletsListManager.unlockWithBiometry()
userWalletsListManager.unlockIfLockable()
.doOnFailure { error ->
store.dispatchOnMain(WelcomeAction.ProceedWithBiometrics.Error(error))
}