Skip to content

Commit

Permalink
adjustments on loading state and re calculate routes debounce
Browse files Browse the repository at this point in the history
  • Loading branch information
briansztamfater committed Mar 28, 2024
1 parent e76df78 commit 341b6f1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
13 changes: 7 additions & 6 deletions src/status_im/contexts/wallet/send/input_amount/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
[utils.address :as address]
[utils.debounce :as debounce]
[utils.i18n :as i18n]
[utils.re-frame :as rf]
[status-im.constants :as constants]))
[utils.re-frame :as rf]))

(defn- make-limit-label
[{:keys [amount currency]}]
Expand Down Expand Up @@ -185,9 +184,12 @@
(if-not (or (empty? @input-value)
(<= input-num-value 0)
(> input-num-value current-limit-amount))
(debounce/debounce-and-dispatch
[:wallet/get-suggested-routes {:amount @input-value}]
bounce-duration-ms)
(if (= bounce-duration-ms 0)
(rf/dispatch [:wallet/get-suggested-routes
{:amount @input-value}])
(debounce/debounce-and-dispatch
[:wallet/get-suggested-routes {:amount @input-value}]
bounce-duration-ms))
(rf/dispatch [:wallet/clean-suggested-routes])))))
handle-on-confirm (fn []
(rf/dispatch [:wallet/send-select-amount
Expand Down Expand Up @@ -252,7 +254,6 @@
(fn []
(let [dismiss-keyboard-fn #(when (= % "active") (rn/dismiss-keyboard!))
app-keyboard-listener (.addEventListener rn/app-state "change" dismiss-keyboard-fn)]
(rf/dispatch [:wallet/disable-from-networks [constants/optimism-sepolia-chain-id]])
#(.remove app-keyboard-listener))))
(rn/use-effect
#(fetch-routes input-num-value (current-limit) 2000)
Expand Down
10 changes: 7 additions & 3 deletions src/status_im/contexts/wallet/send/routes/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@
[utils.re-frame :as rf]))

(defn- find-affordable-networks
[{:keys [balances-per-chain]} input-value selected-networks]
[{:keys [balances-per-chain]} input-value selected-networks disabled-chain-ids]
(->> balances-per-chain
(filter (fn [[_ {:keys [balance chain-id]}]]
(and
(>= (js/parseFloat balance) input-value)
(some #(= % chain-id) selected-networks))))
(some #(= % chain-id) selected-networks)
(not-any? #(= % chain-id) disabled-chain-ids))))
(map first)))

(defn- make-network-item
Expand Down Expand Up @@ -128,7 +129,10 @@
[{:keys [amount routes token input-value theme fetch-routes disabled-from-networks
on-press-from-network on-press-to-network]}]
(let [selected-networks (rf/sub [:wallet/wallet-send-selected-networks])
loading-networks (find-affordable-networks token input-value selected-networks)
loading-networks (find-affordable-networks token
input-value
selected-networks
disabled-from-networks)
loading-suggested-routes? (rf/sub [:wallet/wallet-send-loading-suggested-routes?])
data (if loading-suggested-routes? loading-networks routes)]
(if (or (and (not-empty loading-networks) loading-suggested-routes?) (not-empty routes))
Expand Down

0 comments on commit 341b6f1

Please sign in to comment.