Updated on 2026-08-14

This commit is contained in:
Tangem 2025-09-16 17:39:08 +05:00
parent 8c47e9483c
commit e07cd92e27
8 changed files with 61 additions and 9 deletions

View file

@ -432,7 +432,7 @@ internal class WalletModel @Inject constructor(
is WalletsUpdateActionResolver.Action.RenameWallets -> {
stateHolder.update(transformer = RenameWalletsTransformer(renamedWallets = action.renamedWallets))
}
is WalletsUpdateActionResolver.Action.ReloadWarningsForWallets -> {
is WalletsUpdateActionResolver.Action.ReloadWallets -> {
reloadWarnings(action)
}
WalletsUpdateActionResolver.Action.EmptyWallets -> {
@ -444,7 +444,7 @@ internal class WalletModel @Inject constructor(
}
}
private fun reloadWarnings(action: WalletsUpdateActionResolver.Action.ReloadWarningsForWallets) {
private fun reloadWarnings(action: WalletsUpdateActionResolver.Action.ReloadWallets) {
action.wallets.forEach {
walletScreenContentLoader.load(
userWallet = it,

View file

@ -64,6 +64,9 @@ internal class WalletsUpdateActionResolver @Inject constructor(
selectedWallet: UserWallet,
): Action {
return when {
isHotWalletUpgraded(state, wallets) -> {
getHotWalletsUpgradedAction(state, wallets)
}
isWalletsCountChanged(state, wallets) -> {
getChangeWalletsListAction(state, wallets, selectedWallet)
}
@ -91,6 +94,19 @@ internal class WalletsUpdateActionResolver @Inject constructor(
return walletsToUpdate.isNotEmpty()
}
private fun isHotWalletUpgraded(state: WalletScreenState, wallets: List<UserWallet>): Boolean {
val previousWallet = state
.wallets
.getOrNull(state.selectedWalletIndex)
return when (previousWallet) {
is WalletState.MultiCurrency -> {
val wallet = wallets.firstOrNull { it.walletId == previousWallet.walletCardState.id }
previousWallet.type == WalletState.MultiCurrency.WalletType.Hot && wallet is UserWallet.Cold
}
else -> false
}
}
private fun isWalletsCountChanged(state: WalletScreenState, wallets: List<UserWallet>): Boolean {
val prevWalletsSize = state.wallets.size
val walletsSize = wallets.size
@ -160,14 +176,22 @@ internal class WalletsUpdateActionResolver @Inject constructor(
private fun getHotWalletsBackedUpAction(
state: WalletScreenState,
wallets: List<UserWallet>,
): Action.ReloadWarningsForWallets {
): Action.ReloadWallets {
val incompleteActivationWalletIds = state.incompleteActivationWalletIds()
val walletsToUpdate = wallets.filter {
it is UserWallet.Hot && it.backedUp == incompleteActivationWalletIds.contains(it.walletId)
}
return Action.ReloadWarningsForWallets(walletsToUpdate)
return Action.ReloadWallets(walletsToUpdate)
}
private fun getHotWalletsUpgradedAction(
state: WalletScreenState,
wallets: List<UserWallet>,
): Action.ReloadWallets {
val walletsToUpdate = wallets.filter { it.walletId == state.getPrevSelectedWallet().id }
return Action.ReloadWallets(walletsToUpdate)
}
private fun getRenameWalletsAction(state: WalletScreenState, wallets: List<UserWallet>): Action.RenameWallets {
@ -358,7 +382,7 @@ internal class WalletsUpdateActionResolver @Inject constructor(
}
}
data class ReloadWarningsForWallets(
data class ReloadWallets(
val wallets: List<UserWallet>,
) : Action()

View file

@ -159,6 +159,7 @@ internal object WalletScreenPreviewData {
isFlickering = false,
onItemClick = { },
),
type = WalletState.MultiCurrency.WalletType.Cold,
)
}

View file

@ -99,7 +99,10 @@ internal object WalletAdditionalInfoFactory {
TextReference.EMPTY
}
return WalletAdditionalInfo(hideable = false, content = content)
return WalletAdditionalInfo(
hideable = false,
content = content,
)
}
private fun getBackupInfoTextReference(count: Int): TextReference {
@ -112,12 +115,18 @@ internal object WalletAdditionalInfoFactory {
private fun UserWallet.Cold.resolveSingleCurrencyInfo(currencyAmount: BigDecimal?): WalletAdditionalInfo {
return if (isLocked) {
WalletAdditionalInfo(hideable = false, content = TextReference.Res(R.string.common_locked))
WalletAdditionalInfo(
hideable = false,
content = TextReference.Res(R.string.common_locked),
)
} else {
val blockchain = scanResponse.cardTypesResolver.getBlockchain()
val amount = currencyAmount?.format { crypto(blockchain.currency, blockchain.decimals()) }
WalletAdditionalInfo(hideable = true, content = TextReference.Str(value = amount.orEmpty()))
WalletAdditionalInfo(
hideable = true,
content = TextReference.Str(value = amount.orEmpty()),
)
}
}
}

View file

@ -23,6 +23,7 @@ internal sealed interface WalletState : WalletStateHolder {
abstract val tokensListState: WalletTokensListState
abstract val nftState: WalletNFTItemUM
abstract val type: WalletType
data class Content(
override val pullToRefreshConfig: PullToRefreshConfig,
@ -32,12 +33,14 @@ internal sealed interface WalletState : WalletStateHolder {
override val bottomSheetConfig: TangemBottomSheetConfig?,
override val tokensListState: WalletTokensListState,
override val nftState: WalletNFTItemUM,
override val type: WalletType,
) : MultiCurrency()
data class Locked(
override val walletCardState: WalletCardState,
override val buttons: PersistentList<WalletManageButton>,
override val bottomSheetConfig: TangemBottomSheetConfig?,
override val type: WalletType,
val onUnlockNotificationClick: () -> Unit,
) : MultiCurrency(),
WalletStateHolder by LockedWalletStateHolder(
@ -50,6 +53,11 @@ internal sealed interface WalletState : WalletStateHolder {
override val tokensListState = WalletTokensListState.ContentState.Locked
override val nftState: WalletNFTItemUM = WalletNFTItemUM.Hidden
}
enum class WalletType {
Hot,
Cold,
}
}
sealed class SingleCurrency : WalletState, TxHistoryStateHolder {

View file

@ -9,6 +9,7 @@ import com.tangem.feature.wallet.presentation.wallet.state.model.*
import com.tangem.feature.wallet.presentation.wallet.state.utils.WalletLoadingStateFactory
import com.tangem.feature.wallet.presentation.wallet.state.utils.createStateByWalletType
import com.tangem.feature.wallet.child.wallet.model.intents.WalletClickIntents
import com.tangem.feature.wallet.presentation.wallet.state.model.WalletState.MultiCurrency.WalletType
import kotlinx.collections.immutable.PersistentList
import kotlinx.collections.immutable.persistentListOf
import kotlinx.collections.immutable.toImmutableList
@ -61,6 +62,10 @@ internal class InitializeWalletsTransformer(
buttons = createMultiWalletEnabledButtons(userWallet),
bottomSheetConfig = null,
onUnlockNotificationClick = clickIntents::onOpenUnlockWalletsBottomSheetClick,
type = when (userWallet) {
is UserWallet.Cold -> WalletType.Cold
is UserWallet.Hot -> WalletType.Hot
},
)
},
singleCurrencyCreator = {

View file

@ -106,7 +106,10 @@ internal class SetVisaInfoTransformer(
},
)
return WalletAdditionalInfo(hideable = true, infoContent)
return WalletAdditionalInfo(
hideable = true,
content = infoContent,
)
}
private fun getRefreshTokenExpiredState(prevState: WalletState.Visa.Content): WalletState {

View file

@ -54,6 +54,7 @@ internal class WalletLoadingStateFactory(
bottomSheetConfig = null,
tokensListState = WalletTokensListState.ContentState.Loading,
nftState = WalletNFTItemUM.Hidden,
type = WalletState.MultiCurrency.WalletType.Hot,
)
}
@ -66,6 +67,7 @@ internal class WalletLoadingStateFactory(
bottomSheetConfig = null,
tokensListState = WalletTokensListState.ContentState.Loading,
nftState = WalletNFTItemUM.Hidden,
type = WalletState.MultiCurrency.WalletType.Cold,
)
}