From 199d6d4eb76fa8cbd1ed112c685b0171bb8def56 Mon Sep 17 00:00:00 2001 From: Tangem Date: Wed, 23 Nov 2022 21:19:00 +0400 Subject: [PATCH] Updated on 2026-08-14 --- .../com/tangem/tap/domain/RatesRepository.kt | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/com/tangem/tap/domain/RatesRepository.kt b/app/src/main/java/com/tangem/tap/domain/RatesRepository.kt index 51252c819c..8b4136e90f 100644 --- a/app/src/main/java/com/tangem/tap/domain/RatesRepository.kt +++ b/app/src/main/java/com/tangem/tap/domain/RatesRepository.kt @@ -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> = result.data.rates.mapValues { Result.Success(it.value.toBigDecimal()) } - val updatedCurrencies = mutableMapOf?>() - 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(), - mutableMapOf() - )) - } } typealias RatesResult = Pair, MutableMap>