From c170dd95d5c3da4bfcedefa7aa4eab88a64f6f7a Mon Sep 17 00:00:00 2001 From: Tangem Date: Mon, 25 Dec 2023 17:09:56 +0200 Subject: [PATCH] Updated on 2026-08-14 --- .../tangem/feature/swap/ui/StateBuilder.kt | 8 ++------ .../feature/swap/viewmodels/SwapViewModel.kt | 19 +++++++++++-------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/StateBuilder.kt b/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/StateBuilder.kt index dc89739051..5b22001266 100644 --- a/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/StateBuilder.kt +++ b/features/swap/presentation/src/main/java/com/tangem/feature/swap/ui/StateBuilder.kt @@ -98,12 +98,8 @@ internal class StateBuilder( if (uiStateHolder.sendCardData !is SwapCardState.SwapCardData) return uiStateHolder return uiStateHolder.copy( sendCardData = SwapCardState.SwapCardData( - type = TransactionCardType.ReadOnly( - headerResId = R.string.exchange_send_view_header, - ), - amountTextFieldValue = TextFieldValue( - text = "0", - ), + type = requireNotNull(uiStateHolder.sendCardData.type as? TransactionCardType.Inputtable), + amountTextFieldValue = null, amountEquivalent = "0 ${appCurrencyProvider.invoke().symbol}", token = fromToken, tokenIconUrl = uiStateHolder.sendCardData.tokenIconUrl, diff --git a/features/swap/presentation/src/main/java/com/tangem/feature/swap/viewmodels/SwapViewModel.kt b/features/swap/presentation/src/main/java/com/tangem/feature/swap/viewmodels/SwapViewModel.kt index 8dc1e1a382..ccccda01cc 100644 --- a/features/swap/presentation/src/main/java/com/tangem/feature/swap/viewmodels/SwapViewModel.kt +++ b/features/swap/presentation/src/main/java/com/tangem/feature/swap/viewmodels/SwapViewModel.kt @@ -692,19 +692,22 @@ internal class SwapViewModel @Inject constructor( private fun onAmountChanged(value: String) { val fromToken = dataState.fromCryptoCurrency val toToken = dataState.toCryptoCurrency - if (fromToken != null && toToken != null) { + if (fromToken != null) { val decimals = fromToken.currency.decimals val cutValue = cutAmountWithDecimals(decimals, value) lastAmount.value = cutValue uiState = stateBuilder.updateSwapAmount(uiState, inputNumberFormatter.formatWithThousands(cutValue, decimals)) - amountDebouncer.debounce(viewModelScope, DEBOUNCE_AMOUNT_DELAY) { - startLoadingQuotes( - fromToken = fromToken, - toToken = toToken, - amount = lastAmount.value, - toProvidersList = findSwapProviders(fromToken, toToken), - ) + + if (toToken != null) { + amountDebouncer.debounce(viewModelScope, DEBOUNCE_AMOUNT_DELAY) { + startLoadingQuotes( + fromToken = fromToken, + toToken = toToken, + amount = lastAmount.value, + toProvidersList = findSwapProviders(fromToken, toToken), + ) + } } } }