Updated on 2026-08-14

This commit is contained in:
Tangem 2021-11-10 10:32:41 +03:00
parent b3a198ebb6
commit 35cd32bc8b
4 changed files with 18 additions and 9 deletions

View file

@ -242,7 +242,7 @@ data class WalletData(
val fiatRateString: String? = null,
val fiatRate: BigDecimal? = null,
val mainButton: WalletMainButton = WalletMainButton.SendButton(false),
val currency: Currency? = null
val currency: Currency
) {
fun shouldShowMultipleAddress(): Boolean {
val listOfAddresses = walletAddresses?.list ?: return false

View file

@ -105,7 +105,8 @@ class MultiWalletReducer {
}
),
pendingTransactions = pendingTransactions.removeUnknownTransactions(),
mainButton = WalletMainButton.SendButton(sendButtonEnabled)
mainButton = WalletMainButton.SendButton(sendButtonEnabled),
currency = Currency.Token(action.token)
)
val wallets = state.replaceWalletInWallets(newTokenWalletData)
state.copy(wallets = wallets)

View file

@ -3,12 +3,15 @@ package com.tangem.tap.features.wallet.redux.reducers
import com.tangem.blockchain.common.AmountType
import com.tangem.blockchain.common.Wallet
import com.tangem.common.extensions.isZero
import com.tangem.tap.common.extensions.*
import com.tangem.tap.common.extensions.toFiatString
import com.tangem.tap.common.extensions.toFiatValue
import com.tangem.tap.common.extensions.toFormattedCurrencyString
import com.tangem.tap.common.extensions.toFormattedFiatValue
import com.tangem.tap.domain.getFirstToken
import com.tangem.tap.features.wallet.models.removeUnknownTransactions
import com.tangem.tap.features.wallet.models.toPendingTransactions
import com.tangem.tap.features.wallet.redux.Currency
import com.tangem.tap.features.wallet.redux.ProgressState
import com.tangem.tap.features.wallet.redux.WalletData
import com.tangem.tap.features.wallet.redux.WalletMainButton
import com.tangem.tap.features.wallet.redux.WalletState
import com.tangem.tap.features.wallet.ui.BalanceStatus
@ -49,9 +52,9 @@ class OnWalletLoadedReducer {
BalanceStatus.VerifiedOnline
}
val walletData = walletState.getWalletData(wallet.blockchain)
?: WalletData()
val fiatAmount = walletData.fiatRate?.let { amount?.toFiatValue(it) }
val newWalletData = walletData.copy(
val fiatAmount = walletData?.fiatRate?.let { amount?.toFiatValue(it) }
val newWalletData = walletData?.copy(
currencyData = walletData.currencyData.copy(
status = balanceStatus, currency = wallet.blockchain.fullName,
currencySymbol = wallet.blockchain.currency,
@ -60,7 +63,8 @@ class OnWalletLoadedReducer {
fiatAmountFormatted = fiatAmount?.toFormattedFiatValue(fiatCurrencySymbol)
),
pendingTransactions = pendingTransactions.removeUnknownTransactions(),
mainButton = WalletMainButton.SendButton(sendButtonEnabled)
mainButton = WalletMainButton.SendButton(sendButtonEnabled),
currency = Currency.Blockchain(wallet.blockchain)
)
val tokens = wallet.getTokens().mapNotNull { token ->
@ -87,7 +91,8 @@ class OnWalletLoadedReducer {
mainButton = WalletMainButton.SendButton(sendButtonEnabled)
)
}
val wallets = walletState.replaceSomeWallets((tokens + newWalletData))
val newWallets = (tokens + newWalletData).mapNotNull { it }
val wallets = walletState.replaceSomeWallets((newWallets))
val state = if (wallets.any { it.currencyData.status == BalanceStatus.Loading }) {
ProgressState.Loading

View file

@ -1,6 +1,7 @@
package com.tangem.tap.features.wallet.redux.reducers
import com.tangem.blockchain.common.AmountType
import com.tangem.blockchain.common.Blockchain
import com.tangem.blockchain.common.Wallet
import com.tangem.tap.common.extensions.*
import com.tangem.tap.common.redux.AppState
@ -44,6 +45,7 @@ private fun internalReduce(action: Action, state: AppState): WalletState {
WalletData(
currencyData = BalanceWidgetData(BalanceStatus.EmptyCard),
mainButton = WalletMainButton.CreateWalletButton(true),
currency = Currency.Blockchain(Blockchain.Unknown)
)
)
)
@ -71,6 +73,7 @@ private fun internalReduce(action: Action, state: AppState): WalletState {
wallets = listOf(
WalletData(
currencyData = BalanceWidgetData(BalanceStatus.UnknownBlockchain),
currency = Currency.Blockchain(Blockchain.Unknown)
)
)
)