Updated on 2026-08-14

This commit is contained in:
Tangem 2022-11-23 21:31:54 +04:00
commit 6baaff95f4
3 changed files with 13 additions and 21 deletions

View file

@ -20,21 +20,18 @@ class RatesRepository {
val throttledResult = coinsList.filter { throttler.isStillThrottled(it) }.map {
Pair(it, throttler.geValue(it))
}
if (throttledResult.isNotEmpty()) {
return handleFiatRatesResult(throttledResult.toMap())
}
val currenciesToUpdate = coinsList.filter { !throttler.isStillThrottled(it) }
val coinIds = currenciesToUpdate.mapNotNull { it.coinId }.distinct()
if (coinIds.isEmpty()) return EMPTY_RESULT
if (coinIds.isEmpty()) return handleFiatRatesResult(throttledResult.toMap())
return when (val result = tangemTechService.rates(currencyId, coinIds)) {
is Result.Success -> {
val ratesResultList: Map<String, Result<BigDecimal>> = result.data.rates.mapValues {
Result.Success(it.value.toBigDecimal())
}
val updatedCurrencies = mutableMapOf<Currency, Result<BigDecimal>?>()
currenciesToUpdate.forEach { currency ->
val updatedCurrencies = throttledResult.toMap().toMutableMap()
coinsList.forEach { currency ->
ratesResultList[currency.coinId]?.let {
updatedCurrencies[currency] = it
throttler.updateThrottlingTo(currency)
@ -65,13 +62,6 @@ class RatesRepository {
fun clear() {
throttler.clear()
}
companion object {
val EMPTY_RESULT = Result.Success(Pair(
mutableMapOf<Currency, BigDecimal>(),
mutableMapOf<Currency, Throwable>()
))
}
}
typealias RatesResult = Pair<MutableMap<Currency, BigDecimal>, MutableMap<Currency, Throwable>>

View file

@ -149,14 +149,16 @@ class WalletDetailsFragment : Fragment(R.layout.fragment_wallet_details),
binding.srlWalletDetails.setOnRefreshListener {
if (selectedWallet.currencyData.status != BalanceStatus.Loading) {
store.dispatch(WalletAction.LoadWallet(
blockchain = BlockchainNetwork(
selectedWallet.currency.blockchain,
selectedWallet.currency.derivationPath,
emptyList()
)
)
store.dispatch(
WalletAction.LoadWallet(
blockchain = BlockchainNetwork(
selectedWallet.currency.blockchain,
selectedWallet.currency.derivationPath,
emptyList(),
),
),
)
store.dispatch(WalletAction.LoadFiatRate(coinsList = listOf(selectedWallet.currency)))
}
}

View file

@ -3,7 +3,7 @@ ext.versions = [
build_gradle : '7.1.3',
tangem_card_sdk : 'develop-165',
// tangem_card_sdk : '0.0.1',
tangem_blockchain_sdk: 'develop-135',
tangem_blockchain_sdk: 'develop-139',
// tangem_blockchain_sdk: '0.0.1',
]