Updated on 2026-08-14
This commit is contained in:
parent
04cb29ad22
commit
136b6e7eb3
11 changed files with 50 additions and 37 deletions
|
|
@ -55,6 +55,7 @@ sealed class WalletAction : Action {
|
|||
data class AddBlockchains(val blockchains: List<Blockchain>) : MultiWallet()
|
||||
data class AddTokens(val tokens: List<Token>) : MultiWallet()
|
||||
data class AddToken(val token: Token) : MultiWallet()
|
||||
object FindTokensInUse : MultiWallet()
|
||||
data class TokenLoaded(val amount: Amount) : MultiWallet()
|
||||
data class SelectWallet(val walletData: WalletData?) : MultiWallet()
|
||||
data class RemoveWallet(val walletData: WalletData) : MultiWallet()
|
||||
|
|
|
|||
|
|
@ -49,6 +49,28 @@ class MultiWalletMiddleware {
|
|||
cardId?.let { currenciesRepository.removeBlockchain(it, action.walletData.blockchain) }
|
||||
}
|
||||
}
|
||||
is WalletAction.MultiWallet.FindTokensInUse -> {
|
||||
val walletManager = walletState?.getWalletManager(Blockchain.Ethereum.currency)
|
||||
?: return
|
||||
val alreadyAddedTokens = walletManager.presetTokens
|
||||
val tokenManager = walletManager as TokenManager
|
||||
scope.launch {
|
||||
val result = tokenManager.findTokens()
|
||||
withContext(Dispatchers.Main) {
|
||||
when (result) {
|
||||
is Result.Success -> {
|
||||
if (result.data.isNotEmpty()) {
|
||||
store.dispatch(WalletAction.MultiWallet.AddTokens(
|
||||
walletManager.presetTokens
|
||||
.filterNot { presetToken -> alreadyAddedTokens.any { it.symbol == presetToken.symbol } }
|
||||
.toList()
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -63,8 +85,6 @@ class MultiWalletMiddleware {
|
|||
store.dispatch(WalletAction.LoadFiatRate(currency = token.symbol))
|
||||
store.dispatch(WalletAction.MultiWallet.TokenLoaded(result.data))
|
||||
}
|
||||
is Result.Failure -> null
|
||||
null -> null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import com.tangem.tap.common.extensions.isGreaterThan
|
|||
import com.tangem.tap.common.redux.global.GlobalState
|
||||
import com.tangem.tap.domain.configurable.warningMessage.WarningMessage
|
||||
import com.tangem.tap.domain.configurable.warningMessage.WarningMessagesManager
|
||||
import com.tangem.tap.domain.tasks.isMultiwalletAllowed
|
||||
import com.tangem.tap.domain.isMultiwalletAllowed
|
||||
import com.tangem.tap.domain.twins.isTwinCard
|
||||
import com.tangem.tap.features.wallet.redux.WalletAction
|
||||
import com.tangem.tap.network.NetworkConnectivity
|
||||
|
|
@ -55,7 +55,7 @@ class WarningsMiddleware {
|
|||
}
|
||||
}
|
||||
|
||||
public fun tryToShowAppRatingWarning(wallet: Wallet) {
|
||||
fun tryToShowAppRatingWarning(wallet: Wallet) {
|
||||
val nonZeroWalletsCount = wallet.amounts.filter {
|
||||
it.value.value?.isGreaterThan(BigDecimal.ZERO) ?: false
|
||||
}.size
|
||||
|
|
|
|||
|
|
@ -155,6 +155,7 @@ class MultiWalletReducer {
|
|||
|
||||
is WalletAction.MultiWallet.SetPrimaryToken ->
|
||||
state.copy(primaryToken = action.token)
|
||||
is WalletAction.MultiWallet.FindTokensInUse -> state
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.tangem.tap.features.wallet.redux
|
||||
package com.tangem.tap.features.wallet.redux.reducers
|
||||
|
||||
import com.tangem.blockchain.common.AmountType
|
||||
import com.tangem.blockchain.common.Blockchain
|
||||
|
|
@ -14,9 +14,7 @@ import com.tangem.tap.common.redux.global.FiatCurrencyName
|
|||
import com.tangem.tap.domain.TapError
|
||||
import com.tangem.tap.domain.getFirstToken
|
||||
import com.tangem.tap.domain.twins.TwinCardNumber
|
||||
import com.tangem.tap.features.wallet.redux.reducers.MultiWalletReducer
|
||||
import com.tangem.tap.features.wallet.redux.reducers.OnWalletLoadedReducer
|
||||
import com.tangem.tap.features.wallet.redux.reducers.TwinsReducer
|
||||
import com.tangem.tap.features.wallet.redux.*
|
||||
import com.tangem.tap.features.wallet.ui.BalanceStatus
|
||||
import com.tangem.tap.features.wallet.ui.BalanceWidgetData
|
||||
import org.rekotlin.Action
|
||||
|
|
@ -58,7 +58,6 @@ class WalletDetailsFragment : Fragment(R.layout.fragment_wallet_details), StoreS
|
|||
oldState.walletState == newState.walletState
|
||||
}.select { it.walletState }
|
||||
}
|
||||
store.dispatch(WalletAction.UpdateWallet())
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue