From c63fe7289bfffbf867d51abfea80a0f46ee4396c Mon Sep 17 00:00:00 2001 From: Tangem Date: Fri, 9 Apr 2021 15:15:38 +0300 Subject: [PATCH] Updated on 2026-08-14 --- .../send/redux/middlewares/AmountMiddleware.kt | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/tangem/tap/features/send/redux/middlewares/AmountMiddleware.kt b/app/src/main/java/com/tangem/tap/features/send/redux/middlewares/AmountMiddleware.kt index 08dc775fba..60851b1b83 100644 --- a/app/src/main/java/com/tangem/tap/features/send/redux/middlewares/AmountMiddleware.kt +++ b/app/src/main/java/com/tangem/tap/features/send/redux/middlewares/AmountMiddleware.kt @@ -78,11 +78,17 @@ class AmountMiddleware { } private fun setMaxAmount(appState: AppState?, dispatch: (Action) -> Unit) { - val amountState = appState?.sendState?.amountState ?: return + val sendState = appState?.sendState ?: return + + dispatch(AmountAction.SetAmount(sendState.amountState.balanceCrypto, false)) + + if (sendState.addressPayIdState.destinationWalletAddress == null || sendState.addressPayIdState.error != null) { + // if the destination address is empty or it has an error - prevent requesting the fee + return + } - dispatch(AmountAction.SetAmount(amountState.balanceCrypto, false)) dispatch(FeeAction.RequestFee) - if (!amountState.isCoinAmount()) return + if (!sendState.amountState.isCoinAmount()) return dispatch(FeeAction.ChangeLayoutVisibility(main = true, controls = true, chipGroup = true)) dispatch(FeeActionUi.ChangeIncludeFee(true))