fix(wallet): Exception when navigating back from route generation (#21381)
- Slightly improved code style
This commit is contained in:
parent
131da5f444
commit
a9e0b3dd6b
|
@ -158,16 +158,14 @@
|
||||||
active-screen? (= view-id current-screen-id)
|
active-screen? (= view-id current-screen-id)
|
||||||
bottom (safe-area/get-bottom)
|
bottom (safe-area/get-bottom)
|
||||||
[crypto-currency? set-crypto-currency] (rn/use-state initial-crypto-currency?)
|
[crypto-currency? set-crypto-currency] (rn/use-state initial-crypto-currency?)
|
||||||
on-navigate-back on-navigate-back
|
|
||||||
handle-on-confirm (fn [amount]
|
handle-on-confirm (fn [amount]
|
||||||
(rf/dispatch [:wallet/set-token-amount-to-send
|
(rf/dispatch [:wallet/set-token-amount-to-send
|
||||||
{:amount amount
|
{:amount amount
|
||||||
:stack-id current-screen-id}]))
|
:stack-id current-screen-id}]))
|
||||||
{fiat-currency :currency} (rf/sub [:profile/profile])
|
{fiat-currency :currency} (rf/sub [:profile/profile])
|
||||||
{token-symbol :symbol
|
{token-symbol :symbol
|
||||||
token-networks :networks
|
token-networks :networks
|
||||||
:as
|
:as token} (rf/sub [:wallet/wallet-send-token])
|
||||||
token} (rf/sub [:wallet/wallet-send-token])
|
|
||||||
send-from-locked-amounts (rf/sub [:wallet/wallet-send-from-locked-amounts])
|
send-from-locked-amounts (rf/sub [:wallet/wallet-send-from-locked-amounts])
|
||||||
{:keys [total-balance]
|
{:keys [total-balance]
|
||||||
:as token-by-symbol} (rf/sub [:wallet/token-by-symbol
|
:as token-by-symbol} (rf/sub [:wallet/token-by-symbol
|
||||||
|
@ -196,10 +194,8 @@
|
||||||
(utils/cut-crypto-decimals-to-fit-usd-cents
|
(utils/cut-crypto-decimals-to-fit-usd-cents
|
||||||
token-balance
|
token-balance
|
||||||
usd-conversion-rate)
|
usd-conversion-rate)
|
||||||
(-> (money/crypto->fiat
|
(utils/cut-fiat-balance-to-two-decimals
|
||||||
token-balance
|
(money/crypto->fiat token-balance conversion-rate)))
|
||||||
conversion-rate)
|
|
||||||
utils/cut-fiat-balance-to-two-decimals))
|
|
||||||
input-value (controlled-input/input-value input-state)
|
input-value (controlled-input/input-value input-state)
|
||||||
valid-input? (not (or (controlled-input/empty-value? input-state)
|
valid-input? (not (or (controlled-input/empty-value? input-state)
|
||||||
(controlled-input/input-error input-state)))
|
(controlled-input/input-error input-state)))
|
||||||
|
@ -389,7 +385,8 @@
|
||||||
:button-one-label (if should-try-again?
|
:button-one-label (if should-try-again?
|
||||||
(i18n/label :t/try-again)
|
(i18n/label :t/try-again)
|
||||||
button-one-label)
|
button-one-label)
|
||||||
:button-one-props (merge (when-not should-try-again? button-one-props)
|
:button-one-props (merge (when-not should-try-again?
|
||||||
|
button-one-props)
|
||||||
{:disabled? (or loading-routes?
|
{:disabled? (or loading-routes?
|
||||||
(and (not should-try-again?) confirm-disabled?))
|
(and (not should-try-again?) confirm-disabled?))
|
||||||
:on-press (cond
|
:on-press (cond
|
||||||
|
|
|
@ -10,8 +10,7 @@
|
||||||
[input-amount/view
|
[input-amount/view
|
||||||
{:current-screen-id :screen/wallet.send-input-amount
|
{:current-screen-id :screen/wallet.send-input-amount
|
||||||
:button-one-label (i18n/label :t/review-send)
|
:button-one-label (i18n/label :t/review-send)
|
||||||
:enabled-from-chain-ids (rf/sub
|
:enabled-from-chain-ids (rf/sub [:wallet/wallet-send-enabled-from-chain-ids])
|
||||||
[:wallet/wallet-send-enabled-from-chain-ids])
|
|
||||||
:from-enabled-networks (rf/sub [:wallet/wallet-send-enabled-networks])
|
:from-enabled-networks (rf/sub [:wallet/wallet-send-enabled-networks])
|
||||||
:on-navigate-back (fn []
|
:on-navigate-back (fn []
|
||||||
(rf/dispatch-sync [:wallet/stop-and-clean-suggested-routes])
|
(rf/dispatch-sync [:wallet/stop-and-clean-suggested-routes])
|
||||||
|
|
|
@ -239,9 +239,12 @@
|
||||||
|
|
||||||
(defn crypto->fiat
|
(defn crypto->fiat
|
||||||
[crypto fiat-price]
|
[crypto fiat-price]
|
||||||
(when-let [^js bn (bignumber crypto)]
|
(let [^js crypto-bn (bignumber crypto)
|
||||||
(-> (.times bn ^js (bignumber fiat-price))
|
^js fiat-price-bn (bignumber fiat-price)]
|
||||||
(with-precision 2))))
|
(when (and crypto-bn fiat-price-bn)
|
||||||
|
(-> crypto-bn
|
||||||
|
(.times fiat-price-bn)
|
||||||
|
(with-precision 2)))))
|
||||||
|
|
||||||
(defn sufficient-funds?
|
(defn sufficient-funds?
|
||||||
[^js amount ^js balance]
|
[^js amount ^js balance]
|
||||||
|
|
Loading…
Reference in New Issue