diff --git a/src/status_im/contexts/wallet/account/view.cljs b/src/status_im/contexts/wallet/account/view.cljs index 48d43e6b9f6a..f4ec0ad52e34 100644 --- a/src/status_im/contexts/wallet/account/view.cljs +++ b/src/status_im/contexts/wallet/account/view.cljs @@ -2,7 +2,6 @@ (:require [quo.core :as quo] [react-native.core :as rn] - [reagent.core :as reagent] [status-im.contexts.wallet.account.style :as style] [status-im.contexts.wallet.account.tabs.view :as tabs] [status-im.contexts.wallet.common.account-switcher.view :as account-switcher] @@ -23,54 +22,55 @@ (defn view [] - (let [selected-tab (reagent/atom first-tab-id)] - (fn [] - (let [{:keys [name color formatted-balance - watch-only?]} (rf/sub [:wallet/current-viewing-account]) - customization-color (rf/sub [:profile/customization-color])] - [rn/view {:style {:flex 1}} - [account-switcher/view - {:type :wallet-networks - :on-press #(rf/dispatch [:wallet/close-account-page])}] - [quo/account-overview - {:current-value formatted-balance - :account-name name - :account (if watch-only? :watched-address :default) - :customization-color color}] - [quo/wallet-graph {:time-frame :empty}] - (when (not watch-only?) - [quo/wallet-ctas - {:container-style style/cta-buttons - :send-action (fn [] - (rf/dispatch [:wallet/clean-send-data]) - (rf/dispatch [:wallet/wizard-navigate-forward - {:start-flow? true - :flow-id :wallet-send-flow}])) - :receive-action #(rf/dispatch [:open-modal :screen/wallet.share-address - {:status :receive}]) - :buy-action #(rf/dispatch [:show-bottom-sheet - {:content buy-token/view}]) - :bridge-action (fn [] - (rf/dispatch [:wallet/clean-send-data]) - (rf/dispatch [:wallet/wizard-navigate-forward - {:start-flow? true - :flow-id :wallet-bridge-flow}])) - :swap-action (when (ff/enabled? ::ff/wallet.swap) - #(rf/dispatch [:wallet/start-swap]))}]) - [quo/tabs - {:style style/tabs - :size 32 - :default-active @selected-tab - :data (tabs-data watch-only?) - :on-change (rn/use-callback (fn [tab] - (reset! selected-tab tab))) - :scrollable? true - :scroll-on-press? true}] - [tabs/view {:selected-tab @selected-tab}] - [quo/floating-shell-button - {:jump-to - {:on-press #(rf/dispatch [:shell/navigate-to-jump-to]) - :customization-color customization-color - :label (i18n/label :t/jump-to)}} - {:position :absolute - :bottom 0}]])))) + (let [selected-tab (or (rf/sub [:wallet/account-tab]) first-tab-id) + {:keys [name color formatted-balance + watch-only?]} (rf/sub [:wallet/current-viewing-account]) + customization-color (rf/sub [:profile/customization-color])] + [rn/view {:style {:flex 1}} + [account-switcher/view + {:type :wallet-networks + :on-press (fn [] + (rf/dispatch [:wallet/close-account-page]) + (rf/dispatch [:wallet/select-account-tab first-tab-id]))}] + [quo/account-overview + {:current-value formatted-balance + :account-name name + :account (if watch-only? :watched-address :default) + :customization-color color}] + [quo/wallet-graph {:time-frame :empty}] + (when (not watch-only?) + [quo/wallet-ctas + {:container-style style/cta-buttons + :send-action (fn [] + (rf/dispatch [:wallet/clean-send-data]) + (rf/dispatch [:wallet/wizard-navigate-forward + {:start-flow? true + :flow-id :wallet-send-flow}])) + :receive-action #(rf/dispatch [:open-modal :screen/wallet.share-address + {:status :receive}]) + :buy-action #(rf/dispatch [:show-bottom-sheet + {:content buy-token/view}]) + :bridge-action (fn [] + (rf/dispatch [:wallet/clean-send-data]) + (rf/dispatch [:wallet/wizard-navigate-forward + {:start-flow? true + :flow-id :wallet-bridge-flow}])) + :swap-action (when (ff/enabled? ::ff/wallet.swap) + #(rf/dispatch [:wallet/start-swap]))}]) + [quo/tabs + {:style style/tabs + :size 32 + :default-active selected-tab + :data (tabs-data watch-only?) + :on-change #(rf/dispatch [:wallet/select-account-tab %]) + + :scrollable? true + :scroll-on-press? true}] + [tabs/view {:selected-tab selected-tab}] + [quo/floating-shell-button + {:jump-to + {:on-press #(rf/dispatch [:shell/navigate-to-jump-to]) + :customization-color customization-color + :label (i18n/label :t/jump-to)}} + {:position :absolute + :bottom 0}]])) diff --git a/src/status_im/contexts/wallet/events.cljs b/src/status_im/contexts/wallet/events.cljs index ac03233badfe..a0d2fd1a802b 100644 --- a/src/status_im/contexts/wallet/events.cljs +++ b/src/status_im/contexts/wallet/events.cljs @@ -40,6 +40,10 @@ [:dispatch [:navigate-to :screen/wallet.accounts address]] [:dispatch [:wallet/show-account-created-toast address]]]})) +(rf/reg-event-fx :wallet/select-account-tab + (fn [{:keys [db]} [tab]] + {:db (assoc-in db [:wallet :ui :account-page :active-tab] tab)})) + (rf/reg-event-fx :wallet/switch-current-viewing-account (fn [{:keys [db]} [address]] {:db (assoc-in db [:wallet :current-viewing-account-address] address)})) diff --git a/src/status_im/contexts/wallet/send/events.cljs b/src/status_im/contexts/wallet/send/events.cljs index 643e32356411..f6f2ccebd15b 100644 --- a/src/status_im/contexts/wallet/send/events.cljs +++ b/src/status_im/contexts/wallet/send/events.cljs @@ -337,18 +337,18 @@ (assoc-in [:wallet :transactions] transaction-details) (assoc-in [:wallet :ui :send :transaction-ids] transaction-ids)) :fx [[:dispatch - [:wallet/wizard-navigate-forward - {:current-screen :screen/wallet.transaction-confirmation - :flow-id :wallet-send-flow}]]]}))) + [:wallet/end-transaction-flow]]]}))) -(rf/reg-event-fx :wallet/close-transaction-progress-page +(rf/reg-event-fx :wallet/end-transaction-flow (fn [_] {:fx [[:dispatch [:wallet/clean-scanned-address]] [:dispatch [:wallet/clean-local-suggestions]] [:dispatch [:wallet/clean-send-address]] [:dispatch [:wallet/clean-disabled-from-networks]] [:dispatch [:wallet/select-address-tab nil]] - [:dispatch [:dismiss-modal :screen/wallet.transaction-progress]]]})) + [:dispatch [:wallet/fetch-activities]] + [:dispatch [:wallet/select-account-tab :activity]] + [:dispatch [:dismiss-modal :screen/wallet.transaction-confirmation]]]})) (defn- transaction-data [{:keys [from-address to-address token-address route data eth-transfer?]}] diff --git a/src/status_im/contexts/wallet/send/transaction_progress/view.cljs b/src/status_im/contexts/wallet/send/transaction_progress/view.cljs index 4f08455a6d59..06560ca43800 100644 --- a/src/status_im/contexts/wallet/send/transaction_progress/view.cljs +++ b/src/status_im/contexts/wallet/send/transaction_progress/view.cljs @@ -45,7 +45,7 @@ (defn view [] - (let [leave-page #(rf/dispatch [:wallet/close-transaction-progress-page]) + (let [leave-page #(rf/dispatch [:wallet/end-transaction-flow]) {:keys [color]} (rf/sub [:wallet/current-viewing-account])] (fn [] (rn/use-effect diff --git a/src/status_im/subs/wallet/wallet.cljs b/src/status_im/subs/wallet/wallet.cljs index d89cf853ae83..1f4416b93ed7 100644 --- a/src/status_im/subs/wallet/wallet.cljs +++ b/src/status_im/subs/wallet/wallet.cljs @@ -320,6 +320,12 @@ (fn [accounts] (remove :watch-only? accounts))) +(rf/reg-sub + :wallet/account-tab + :<- [:wallet/ui] + (fn [ui] + (get-in ui [:account-page :active-tab]))) + (rf/reg-sub :wallet/current-viewing-account-token-values :<- [:wallet/current-viewing-account]