From 7fcabe68fa9d717e74a523d6941bf79c965fde14 Mon Sep 17 00:00:00 2001 From: Tangem Date: Wed, 18 Dec 2024 22:56:10 +0500 Subject: [PATCH] Updated on 2026-08-14 --- .../main/model/OnrampMainComponentModel.kt | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/main/model/OnrampMainComponentModel.kt b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/main/model/OnrampMainComponentModel.kt index ddcbb59d1c..ef27622623 100644 --- a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/main/model/OnrampMainComponentModel.kt +++ b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/main/model/OnrampMainComponentModel.kt @@ -278,10 +278,11 @@ internal class OnrampMainComponentModel @Inject constructor( private fun handleQuoteResult(quotes: List) { sendOnrampQuotesErrorAnalytic(quotes) - val quote = quotes.firstOrNull() + val quote = quotes.firstOrNull { it !is OnrampQuote.Error } if (quote == null) { _state.update { stateFactory.getErrorState() } + lastAmount.value = BigDecimal.ZERO return } @@ -295,15 +296,17 @@ internal class OnrampMainComponentModel @Inject constructor( val isBestProvider = quote == bestProvider && hasBestProvider - if (quote is OnrampQuote.Data && lastAmount.value != quote.fromAmount.value) { + if (lastAmount.value != quote.fromAmount.value) { lastAmount.value = quote.fromAmount.value - analyticsEventHandler.send( - OnrampAnalyticsEvent.ProviderCalculated( - providerName = quote.provider.info.name, - tokenSymbol = params.cryptoCurrency.symbol, - paymentMethod = quote.paymentMethod.name, - ), - ) + if (quote is OnrampQuote.Data) { + analyticsEventHandler.send( + OnrampAnalyticsEvent.ProviderCalculated( + providerName = quote.provider.info.name, + tokenSymbol = params.cryptoCurrency.symbol, + paymentMethod = quote.paymentMethod.name, + ), + ) + } _state.update { amountStateFactory.getAmountSecondaryUpdatedState( quote = quote,