Updated on 2026-08-14

This commit is contained in:
Tangem 2022-05-20 22:52:44 +03:00
parent d9e745fbc6
commit ac620f6c21

View file

@ -29,7 +29,6 @@ import com.tangem.tap.domain.extensions.makeWalletManagerForApp
import com.tangem.tap.domain.tokens.BlockchainNetwork
import com.tangem.tap.features.wallet.redux.Currency
import com.tangem.tap.features.wallet.redux.WalletAction
import kotlinx.coroutines.async
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import org.rekotlin.Middleware
@ -54,13 +53,10 @@ class TokensMiddleware {
val isTestcard = scanResponse?.card?.isTestCard ?: false
scope.launch {
val currencies = async {
currenciesRepository.getSupportedTokens(isTestcard)
.filter(action.supportedBlockchains?.toSet())
}
val delay = async { delay(600) }
delay.await()
store.dispatchOnMain(TokensAction.LoadCurrencies.Success(currencies.await()))
val currencies = currenciesRepository.getSupportedTokens(isTestcard)
.filter(action.supportedBlockchains?.toSet())
delay(600)
store.dispatchOnMain(TokensAction.LoadCurrencies.Success(currencies))
}
}
@ -78,8 +74,8 @@ class TokensMiddleware {
val blockchainsToRemove = currentBlockchains.filter { !action.addedBlockchains.contains(it) }
val tokensToAdd = action.addedTokens.filter { !currentTokens.contains(it) }
val tokensToRemove = currentTokens.filter {
token -> !action.addedTokens.any { it.token == token.token }
val tokensToRemove = currentTokens.filter { token ->
!action.addedTokens.any { it.token == token.token }
}
val derivationStyle = scanResponse.card.derivationStyle