Fix `div` error after amount is set as fiat (#21732)

* fix: cleanup send state on input unmount

* fix: switching default val to fiat filled input with 0.00
This commit is contained in:
Lungu Cristian 2024-12-05 09:53:57 +02:00 committed by GitHub
parent 6ce58db7b9
commit caaff74efe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 17 additions and 14 deletions

View File

@ -150,15 +150,19 @@
(defn- fiat->crypto
[value conversion-rate]
(if-not (string/blank? value)
(-> value
(money/fiat->crypto conversion-rate)
(wallet-utils/cut-crypto-decimals-to-fit-usd-cents conversion-rate)))
(wallet-utils/cut-crypto-decimals-to-fit-usd-cents conversion-rate))
""))
(defn- crypto->fiat
[value conversion-rate]
(if-not (string/blank? value)
(-> value
(money/crypto->fiat conversion-rate)
(wallet-utils/cut-fiat-balance-to-two-decimals)))
(wallet-utils/cut-fiat-balance-to-two-decimals))
""))
(defn ->crypto
[state conversion-rate]

View File

@ -612,7 +612,7 @@
(rf/reg-event-fx :wallet/clean-up-transaction-flow
(fn [_]
{:fx [[:dispatch [:dismiss-modal :screen/wallet.transaction-confirmation]]
{:fx [[:dispatch [:wallet/clean-send-data]]
[:dispatch [:wallet/clean-scanned-address]]
[:dispatch [:wallet/clean-local-suggestions]]
[:dispatch [:wallet/clean-send-address]]
@ -622,11 +622,9 @@
(rf/reg-event-fx :wallet/end-transaction-flow
(fn [{:keys [db]}]
(let [address (get-in db [:wallet :current-viewing-account-address])]
{:fx [[:dispatch [:wallet/navigate-to-account-within-stack address]]
[:dispatch [:wallet/select-account-tab :activity]]
[:dispatch-later
[{:ms 20
:dispatch [:wallet/clean-up-transaction-flow]}]]]})))
{:fx [[:dispatch [:dismiss-modal :screen/wallet.transaction-confirmation]]
[:dispatch [:wallet/navigate-to-account-within-stack address]]
[:dispatch [:wallet/select-account-tab :activity]]]})))
(rf/reg-event-fx
:wallet/build-transactions-from-route
@ -693,7 +691,6 @@
:params [{:uuid (get-in transaction-for-signing [:sendDetails :uuid])
:signatures signatures-map}]
:on-success (fn []
(rf/dispatch [:wallet/clean-send-data])
(rf/dispatch [:hide-bottom-sheet]))
:on-error (fn [error]
(log/error "failed to send router transactions with signatures"

View File

@ -258,6 +258,8 @@
(set-input-state
#(controlled-input/->crypto % conversion-rate)))
(set-crypto-currency (not crypto-currency?)))]
(rn/use-unmount
#(rf/dispatch [:wallet/clean-up-transaction-flow]))
(rn/use-effect
(fn []
(when active-screen?

View File

@ -25,7 +25,7 @@
[utils.re-frame :as rf]
[utils.string :as utils.string]))
(def ^:private default-text-for-unfocused-input "0.00")
(def ^:private default-text-for-unfocused-input "0")
(def ^:private swap-proposal-debounce-time-ms 1000)
(defn- on-close