fix: hardware induced back actions (#20183)
* fix: hardware induced back actions (#20183)
This commit is contained in:
parent
087fcb1010
commit
0e6d59b312
|
@ -7,6 +7,7 @@
|
|||
[status-im.contexts.wallet.common.account-switcher.view :as account-switcher]
|
||||
[status-im.contexts.wallet.sheets.buy-token.view :as buy-token]
|
||||
[status-im.feature-flags :as ff]
|
||||
[status-im.setup.hot-reload :as hot-reload]
|
||||
[utils.i18n :as i18n]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
|
@ -28,14 +29,15 @@
|
|||
{:keys [name color formatted-balance
|
||||
watch-only?]} (rf/sub [:wallet/current-viewing-account])
|
||||
customization-color (rf/sub [:profile/customization-color])]
|
||||
(rn/use-unmount #(rf/dispatch [:wallet/clean-send-data]))
|
||||
(hot-reload/use-safe-unmount (fn []
|
||||
(rf/dispatch [:wallet/close-account-page])
|
||||
(rf/dispatch [:wallet/clean-current-viewing-account])))
|
||||
(rn/use-mount
|
||||
#(rf/dispatch [:wallet/fetch-activities-for-current-account]))
|
||||
[rn/view {:style {:flex 1}}
|
||||
[account-switcher/view
|
||||
{:type :wallet-networks
|
||||
:on-press (fn []
|
||||
(rf/dispatch [:wallet/close-account-page]))}]
|
||||
:on-press #(rf/dispatch [:pop-to-root :shell-stack])}]
|
||||
[quo/account-overview
|
||||
{:container-style style/account-overview
|
||||
:current-value formatted-balance
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
[status-im.common.floating-button-page.view :as floating-button-page]
|
||||
[status-im.contexts.wallet.add-account.create-account.import-private-key.style :as style]
|
||||
[status-im.contexts.wallet.common.validation :as v]
|
||||
[status-im.setup.hot-reload :as hot-reload]
|
||||
[utils.debounce :as debounce]
|
||||
[utils.i18n :as i18n]
|
||||
[utils.re-frame :as rf]))
|
||||
|
@ -112,7 +113,7 @@
|
|||
public-address (rf/sub [:wallet/public-address])
|
||||
[flow-state set-flow-state] (rn/use-state nil)
|
||||
error? (= :invalid-private-key flow-state)]
|
||||
(rn/use-unmount on-unmount)
|
||||
(hot-reload/use-safe-unmount on-unmount)
|
||||
[rn/view {:flex 1}
|
||||
[floating-button-page/view
|
||||
{:customization-color customization-color
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
[status-im.contexts.wallet.common.utils :as common.utils]
|
||||
[status-im.contexts.wallet.sheets.account-origin.view :as account-origin]
|
||||
[status-im.feature-flags :as ff]
|
||||
[status-im.setup.hot-reload :as hot-reload]
|
||||
[utils.i18n :as i18n]
|
||||
[utils.re-frame :as rf]
|
||||
[utils.responsiveness :as responsiveness]
|
||||
|
@ -313,7 +314,7 @@
|
|||
error (or @account-name-error @emoji-and-color-error?)]
|
||||
|
||||
(rn/use-mount #(check-emoji-and-color-error @emoji @account-color))
|
||||
(rn/use-unmount #(rf/dispatch [:wallet/clear-create-account]))
|
||||
(hot-reload/use-safe-unmount #(rf/dispatch [:wallet/clear-create-account]))
|
||||
|
||||
(if keypair-name
|
||||
[add-new-keypair-variant
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
[status-im.contexts.wallet.common.account-switcher.view :as account-switcher]
|
||||
[status-im.contexts.wallet.common.utils :as utils]
|
||||
[status-im.contexts.wallet.common.utils.networks :as network-utils]
|
||||
[status-im.setup.hot-reload :as hot-reload]
|
||||
[utils.i18n :as i18n]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
|
@ -52,7 +53,7 @@
|
|||
bridge-to-title (i18n/label :t/bridge-to
|
||||
{:name (string/upper-case (str token-symbol))})]
|
||||
|
||||
(rn/use-unmount #(rf/dispatch [:wallet/clean-bridge-to-selection]))
|
||||
(hot-reload/use-safe-unmount #(rf/dispatch [:wallet/clean-bridge-to-selection]))
|
||||
|
||||
[rn/view
|
||||
[account-switcher/view
|
||||
|
|
|
@ -3,12 +3,13 @@
|
|||
[react-native.core :as rn]
|
||||
[status-im.contexts.wallet.bridge.input-amount.style :as style]
|
||||
[status-im.contexts.wallet.send.input-amount.view :as input-amount]
|
||||
[status-im.setup.hot-reload :as hot-reload]
|
||||
[utils.i18n :as i18n]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
(defn view
|
||||
[]
|
||||
(rn/use-unmount #(rf/dispatch [:wallet/clean-routes-calculation]))
|
||||
(hot-reload/use-safe-unmount #(rf/dispatch [:wallet/clean-routes-calculation]))
|
||||
[rn/view {:style style/bridge-send-wrapper}
|
||||
[input-amount/view
|
||||
{:current-screen-id :screen/wallet.bridge-input-amount
|
||||
|
@ -20,5 +21,4 @@
|
|||
:stack-id :screen/wallet.bridge-input-amount}]))
|
||||
:on-navigate-back (fn []
|
||||
(rf/dispatch [:wallet/clean-disabled-from-networks])
|
||||
(rf/dispatch [:wallet/clean-send-amount])
|
||||
(rf/dispatch [:navigate-back]))}]])
|
||||
(rf/dispatch [:wallet/clean-send-amount]))}]])
|
||||
|
|
|
@ -66,13 +66,15 @@
|
|||
|
||||
(rf/reg-event-fx :wallet/clean-current-viewing-account
|
||||
(fn [{:keys [db]}]
|
||||
{:db (update db :wallet dissoc :current-viewing-account-address)}))
|
||||
(let [just-completed-transaction? (get-in db [:wallet :ui :send :just-completed-transaction?])]
|
||||
(when-not just-completed-transaction?
|
||||
{:db (update db :wallet dissoc :current-viewing-account-address)}))))
|
||||
|
||||
(rf/reg-event-fx :wallet/close-account-page
|
||||
(fn [_]
|
||||
{:fx [[:dispatch [:wallet/clean-current-viewing-account]]
|
||||
[:dispatch [:wallet/clear-account-tab]]
|
||||
[:dispatch [:pop-to-root :shell-stack]]]}))
|
||||
(fn [{:keys [db]}]
|
||||
(let [just-completed-transaction? (get-in db [:wallet :ui :send :just-completed-transaction?])]
|
||||
(when-not just-completed-transaction?
|
||||
{:fx [[:dispatch [:wallet/clear-account-tab]]]}))))
|
||||
|
||||
(defn log-rpc-error
|
||||
[_ [{:keys [event params]} error]]
|
||||
|
|
|
@ -487,10 +487,18 @@
|
|||
transaction-details (send-utils/map-multitransaction-by-ids transaction-batch-id
|
||||
transaction-hashes)]
|
||||
{:db (-> db
|
||||
(assoc-in [:wallet :ui :send :just-completed-transaction?] true)
|
||||
(assoc-in [:wallet :transactions] transaction-details)
|
||||
(assoc-in [:wallet :ui :send :transaction-ids] transaction-ids))
|
||||
:fx [[:dispatch
|
||||
[:wallet/end-transaction-flow]]]})))
|
||||
[:wallet/end-transaction-flow]]
|
||||
[:dispatch-later
|
||||
[{:ms 2000
|
||||
:dispatch [:wallet/clean-just-completed-transaction]}]]]})))
|
||||
|
||||
(rf/reg-event-fx :wallet/clean-just-completed-transaction
|
||||
(fn [{:keys [db]}]
|
||||
{:db (update-in db [:wallet :ui :send] dissoc :just-completed-transaction?)}))
|
||||
|
||||
(rf/reg-event-fx :wallet/clean-up-transaction-flow
|
||||
(fn [_]
|
||||
|
@ -659,8 +667,8 @@
|
|||
{:json-rpc/call [{:method "wallet_createMultiTransaction"
|
||||
:params request-params
|
||||
:on-success (fn [result]
|
||||
(rf/dispatch [:hide-bottom-sheet])
|
||||
(rf/dispatch [:wallet/add-authorized-transaction result]))
|
||||
(rf/dispatch [:wallet/add-authorized-transaction result])
|
||||
(rf/dispatch [:hide-bottom-sheet]))
|
||||
:on-error (fn [error]
|
||||
(log/error "failed to send transaction"
|
||||
{:event :wallet/send-transaction
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
[status-im.common.floating-button-page.view :as floating-button-page]
|
||||
[status-im.contexts.wallet.common.account-switcher.view :as account-switcher]
|
||||
[status-im.contexts.wallet.send.from.style :as style]
|
||||
[status-im.setup.hot-reload :as hot-reload]
|
||||
[utils.i18n :as i18n]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
|
@ -18,9 +19,7 @@
|
|||
|
||||
(defn- on-close
|
||||
[]
|
||||
(rf/dispatch [:wallet/clean-current-viewing-account])
|
||||
(rf/dispatch [:wallet/clean-send-data])
|
||||
(rf/dispatch [:navigate-back]))
|
||||
(rf/dispatch [:wallet/clean-current-viewing-account]))
|
||||
|
||||
(defn- render-fn
|
||||
[item _ _ {:keys [network-details]}]
|
||||
|
@ -36,10 +35,11 @@
|
|||
[]
|
||||
(let [accounts (rf/sub [:wallet/accounts-with-current-asset])
|
||||
network-details (rf/sub [:wallet/network-details])]
|
||||
(hot-reload/use-safe-unmount on-close)
|
||||
[floating-button-page/view
|
||||
{:footer-container-padding 0
|
||||
:header [account-switcher/view
|
||||
{:on-press on-close
|
||||
{:on-press #(rf/dispatch [:navigate-back])
|
||||
:margin-top (safe-area/get-top)
|
||||
:switcher-type :select-account}]}
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
[status-im.contexts.wallet.sheets.buy-token.view :as buy-token]
|
||||
[status-im.contexts.wallet.sheets.unpreferred-networks-alert.view :as unpreferred-networks-alert]
|
||||
[status-im.feature-flags :as ff]
|
||||
[status-im.setup.hot-reload :as hot-reload]
|
||||
[utils.debounce :as debounce]
|
||||
[utils.i18n :as i18n]
|
||||
[utils.money :as money]
|
||||
|
@ -322,6 +323,7 @@
|
|||
(let [dismiss-keyboard-fn #(when (= % "active") (rn/dismiss-keyboard!))
|
||||
app-keyboard-listener (.addEventListener rn/app-state "change" dismiss-keyboard-fn)]
|
||||
#(.remove app-keyboard-listener))))
|
||||
(hot-reload/use-safe-unmount on-navigate-back)
|
||||
(rn/use-effect
|
||||
(fn []
|
||||
(set-input-state #(controlled-input/set-upper-limit % current-limit)))
|
||||
|
@ -346,7 +348,7 @@
|
|||
(when (controlled-input/input-error input-state) "-error"))}
|
||||
[account-switcher/view
|
||||
{:icon-name :i/arrow-left
|
||||
:on-press on-navigate-back
|
||||
:on-press #(rf/dispatch [:navigate-back])
|
||||
:switcher-type :select-account}]
|
||||
[quo/token-input
|
||||
{:container-style style/input-container
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
[status-im.contexts.wallet.send.select-address.style :as style]
|
||||
[status-im.contexts.wallet.send.select-address.tabs.view :as tabs]
|
||||
[status-im.feature-flags :as ff]
|
||||
[status-im.setup.hot-reload :as hot-reload]
|
||||
[utils.debounce :as debounce]
|
||||
[utils.i18n :as i18n]
|
||||
[utils.re-frame :as rf]))
|
||||
|
@ -176,8 +177,7 @@
|
|||
(rf/dispatch [:wallet/clean-selected-collectible])
|
||||
(rf/dispatch [:wallet/clean-send-address])
|
||||
(rf/dispatch [:wallet/clean-disabled-from-networks])
|
||||
(rf/dispatch [:wallet/select-address-tab nil])
|
||||
(rf/dispatch [:navigate-back]))
|
||||
(rf/dispatch [:wallet/select-address-tab nil]))
|
||||
on-change-tab #(rf/dispatch [:wallet/select-address-tab %])
|
||||
input-value (reagent/atom "")
|
||||
input-focused? (reagent/atom false)]
|
||||
|
@ -185,12 +185,13 @@
|
|||
(let [selected-tab (or (rf/sub [:wallet/send-tab]) (:id (first tabs-data)))
|
||||
valid-ens-or-address? (boolean (rf/sub [:wallet/valid-ens-or-address?]))
|
||||
searching-address? (rf/sub [:wallet/searching-address?])]
|
||||
(hot-reload/use-safe-unmount on-close)
|
||||
[floating-button-page/view
|
||||
{:content-container-style {:flex 1}
|
||||
:footer-container-padding 0
|
||||
:keyboard-should-persist-taps true
|
||||
:header [account-switcher/view
|
||||
{:on-press on-close
|
||||
{:on-press #(rf/dispatch [:navigate-back])
|
||||
:margin-top (safe-area/get-top)
|
||||
:switcher-type :select-account}]
|
||||
:footer (when-not (string/blank? @input-value)
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
[status-im.contexts.wallet.common.asset-list.view :as asset-list]
|
||||
[status-im.contexts.wallet.common.collectibles-tab.view :as collectibles-tab]
|
||||
[status-im.contexts.wallet.send.select-asset.style :as style]
|
||||
[status-im.setup.hot-reload :as hot-reload]
|
||||
[utils.i18n :as i18n]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
|
@ -66,9 +67,9 @@
|
|||
(rf/dispatch [:wallet/clean-selected-token])
|
||||
(rf/dispatch [:wallet/clean-selected-collectible])
|
||||
(rf/dispatch [:navigate-back]))]
|
||||
(rn/use-unmount (fn []
|
||||
(rf/dispatch [:wallet/clean-selected-token])
|
||||
(rf/dispatch [:wallet/clean-selected-collectible])))
|
||||
(hot-reload/use-safe-unmount (fn []
|
||||
(rf/dispatch [:wallet/clean-selected-token])
|
||||
(rf/dispatch [:wallet/clean-selected-collectible])))
|
||||
[rn/safe-area-view {:style style/container}
|
||||
[account-switcher/view
|
||||
{:icon-name :i/arrow-left
|
||||
|
|
|
@ -13,5 +13,4 @@
|
|||
:on-navigate-back (fn []
|
||||
(rf/dispatch [:wallet/clean-disabled-from-networks])
|
||||
(rf/dispatch [:wallet/clean-from-locked-amounts])
|
||||
(rf/dispatch [:wallet/clean-send-amount])
|
||||
(rf/dispatch [:navigate-back]))}])
|
||||
(rf/dispatch [:wallet/clean-send-amount]))}])
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
[status-im.contexts.wallet.common.account-switcher.view :as account-switcher]
|
||||
[status-im.contexts.wallet.common.asset-list.view :as asset-list]
|
||||
[status-im.contexts.wallet.swap.select-asset-to-pay.style :as style]
|
||||
[status-im.setup.hot-reload :as hot-reload]
|
||||
[utils.i18n :as i18n]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
|
@ -40,8 +41,8 @@
|
|||
on-close (fn []
|
||||
(rf/dispatch [:wallet.swap/clean-asset-to-pay])
|
||||
(rf/dispatch [:navigate-back]))]
|
||||
(rn/use-unmount (fn []
|
||||
(rf/dispatch [:wallet.swap/clean-asset-to-pay])))
|
||||
(hot-reload/use-safe-unmount (fn []
|
||||
(rf/dispatch [:wallet.swap/clean-asset-to-pay])))
|
||||
[rn/safe-area-view {:style style/container}
|
||||
[account-switcher/view
|
||||
{:on-press on-close
|
||||
|
|
|
@ -25,6 +25,11 @@
|
|||
:<- [:wallet/wallet-send]
|
||||
:-> :transaction-ids)
|
||||
|
||||
(rf/reg-sub
|
||||
:wallet/just-completed-transaction
|
||||
:<- [:wallet/wallet-send]
|
||||
:-> :just-completed-transaction?)
|
||||
|
||||
(rf/reg-sub
|
||||
:wallet/wallet-send-amount
|
||||
:<- [:wallet/wallet-send]
|
||||
|
|
Loading…
Reference in New Issue