Updated on 2026-08-14
This commit is contained in:
parent
8f559d4664
commit
285eb9d213
4 changed files with 14 additions and 21 deletions
|
|
@ -75,11 +75,6 @@ class TapWalletManager {
|
|||
loadFiatRate(fiatCurrency, currencies)
|
||||
}
|
||||
|
||||
suspend fun loadFiatRate(fiatCurrency: FiatCurrencyName, currency: Currency) {
|
||||
val currencies = listOf(currency)
|
||||
loadFiatRate(fiatCurrency, currencies)
|
||||
}
|
||||
|
||||
suspend fun loadFiatRate(fiatCurrency: FiatCurrencyName, currencies: List<Currency>) {
|
||||
val results = mutableListOf<Pair<Currency, Result<BigDecimal>?>>()
|
||||
currencies.forEach {
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ sealed class WalletAction : Action {
|
|||
}
|
||||
|
||||
data class LoadFiatRate(
|
||||
val wallet: Wallet? = null, val currency: Currency? = null,
|
||||
val wallet: Wallet? = null, val currencyList: List<Currency>? = null,
|
||||
) : WalletAction() {
|
||||
data class Success(val fiatRate: Pair<Currency, BigDecimal?>) : WalletAction()
|
||||
object Failure : WalletAction()
|
||||
|
|
|
|||
|
|
@ -61,7 +61,9 @@ class MultiWalletMiddleware {
|
|||
}
|
||||
}
|
||||
}
|
||||
store.dispatch(WalletAction.LoadFiatRate(currency = Currency.Blockchain(action.blockchain)))
|
||||
store.dispatch(WalletAction.LoadFiatRate(
|
||||
currencyList = listOf(Currency.Blockchain(action.blockchain)))
|
||||
)
|
||||
store.dispatch(WalletAction.LoadWallet(action.blockchain)
|
||||
)
|
||||
}
|
||||
|
|
@ -184,7 +186,7 @@ class MultiWalletMiddleware {
|
|||
store.dispatch(WalletAction.MultiWallet.AddWalletManagers(it))
|
||||
store.dispatch(WalletAction.MultiWallet.AddBlockchain(blockchain))
|
||||
}
|
||||
tokensList.forEach { store.dispatch(WalletAction.LoadFiatRate(currency = Currency.Token(it))) }
|
||||
store.dispatch(WalletAction.LoadFiatRate(currencyList = tokensList.map { Currency.Token(it) }))
|
||||
walletManager?.apply { addTokens(tokensList) }
|
||||
}
|
||||
scope.launch {
|
||||
|
|
|
|||
|
|
@ -87,23 +87,19 @@ class WalletMiddleware {
|
|||
warningsMiddleware.tryToShowAppRatingWarning(action.wallet)
|
||||
}
|
||||
is WalletAction.LoadFiatRate -> {
|
||||
val tapWalletManager = globalState.tapWalletManager
|
||||
val fiatAppCurrency = globalState.appCurrency
|
||||
scope.launch {
|
||||
when {
|
||||
action.wallet != null -> {
|
||||
globalState.tapWalletManager.loadFiatRate(
|
||||
globalState.appCurrency, action.wallet
|
||||
)
|
||||
tapWalletManager.loadFiatRate(fiatAppCurrency, action.wallet)
|
||||
}
|
||||
action.currency != null -> {
|
||||
globalState.tapWalletManager.loadFiatRate(
|
||||
globalState.appCurrency, action.currency
|
||||
)
|
||||
action.currencyList != null -> {
|
||||
tapWalletManager.loadFiatRate(fiatAppCurrency, action.currencyList)
|
||||
}
|
||||
else -> {
|
||||
globalState.tapWalletManager.loadFiatRate(
|
||||
fiatCurrency = globalState.appCurrency,
|
||||
currencies = walletState.walletsData.mapNotNull { it.currency }
|
||||
)
|
||||
val currencyList = walletState.walletsData.map { it.currency }
|
||||
tapWalletManager.loadFiatRate(fiatAppCurrency, currencyList)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -217,12 +213,12 @@ class WalletMiddleware {
|
|||
when (currency) {
|
||||
is Currency.Blockchain -> {
|
||||
val amountToSend = amounts?.find { it.currencySymbol == currency.blockchain.currency }
|
||||
?: return WalletAction.Send.ChooseCurrency(amounts)
|
||||
?: return WalletAction.Send.ChooseCurrency(amounts)
|
||||
PrepareSendScreen(amountToSend, selectedWalletData.fiatRate, walletManager)
|
||||
}
|
||||
is Currency.Token -> {
|
||||
val amountToSend = amounts?.find { it.currencySymbol == currency.token.symbol }
|
||||
?: return WalletAction.Send.ChooseCurrency(amounts)
|
||||
?: return WalletAction.Send.ChooseCurrency(amounts)
|
||||
prepareSendActionForToken(amountToSend, state, selectedWalletData, wallet, walletManager)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue