From c7aa10c789504022511d3e542f79afc17f8e5767 Mon Sep 17 00:00:00 2001 From: mmilad75 <55688834+mmilad75@users.noreply.github.com> Date: Tue, 20 Feb 2024 15:04:33 +0000 Subject: [PATCH] The last collectible is shown for a moment while opening a new collectible #18750 (#18793) * fix issue * move navigation to the event * move clearing to hook * revert scroll_page * resolve comment * fix duplicate navigation --- src/status_im/contexts/wallet/account/tabs/view.cljs | 3 +-- src/status_im/contexts/wallet/collectible/view.cljs | 10 +++++++++- src/status_im/contexts/wallet/events/collectibles.cljs | 8 +++++++- src/status_im/contexts/wallet/home/tabs/view.cljs | 3 +-- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/status_im/contexts/wallet/account/tabs/view.cljs b/src/status_im/contexts/wallet/account/tabs/view.cljs index b9f675fe71..194a0a9bfd 100644 --- a/src/status_im/contexts/wallet/account/tabs/view.cljs +++ b/src/status_im/contexts/wallet/account/tabs/view.cljs @@ -19,8 +19,7 @@ :collectibles [collectibles/view {:collectibles collectible-list :on-collectible-press (fn [{:keys [id]}] - (rf/dispatch [:wallet/get-collectible-details id]) - (rf/dispatch [:navigate-to :wallet-collectible]))}] + (rf/dispatch [:wallet/get-collectible-details id]))}] :activity [activity/view] :permissions [empty-tab/view {:title (i18n/label :t/no-permissions) diff --git a/src/status_im/contexts/wallet/collectible/view.cljs b/src/status_im/contexts/wallet/collectible/view.cljs index ca6a293467..44a76f2cfc 100644 --- a/src/status_im/contexts/wallet/collectible/view.cljs +++ b/src/status_im/contexts/wallet/collectible/view.cljs @@ -99,7 +99,7 @@ :label (i18n/label :t/share-collectible) :right-icon :i/external}]]])) -(defn view-internal +(defn f-view-internal [{:keys [theme] :as _props}] (let [selected-tab (reagent/atom :overview) on-tab-change #(reset! selected-tab %)] @@ -116,6 +116,10 @@ {collection-image :image-url collection-name :name} collection-data {collectible-name :name} collectible-data] + (rn/use-effect + (fn [] + #(rf/dispatch [:wallet/clear-last-collectible-details])) + []) [scroll-page/scroll-page {:navigate-back? true :height 148 @@ -177,4 +181,8 @@ :data tabs-data}] [tabs/view {:selected-tab @selected-tab}]]])))) +(defn- view-internal + [props] + [:f> f-view-internal props]) + (def view (quo.theme/with-theme view-internal)) diff --git a/src/status_im/contexts/wallet/events/collectibles.cljs b/src/status_im/contexts/wallet/events/collectibles.cljs index f287759f21..5157896738 100644 --- a/src/status_im/contexts/wallet/events/collectibles.cljs +++ b/src/status_im/contexts/wallet/events/collectibles.cljs @@ -56,7 +56,8 @@ (defn store-last-collectible-details [{:keys [db]} [collectible]] - {:db (assoc-in db [:wallet :last-collectible-details] collectible)}) + {:db (assoc-in db [:wallet :last-collectible-details] collectible) + :dispatch [:navigate-to :wallet-collectible]}) (rf/reg-event-fx :wallet/store-last-collectible-details store-last-collectible-details) @@ -126,3 +127,8 @@ (log/error "failed to get collectible details" {:event :wallet/get-collectible-details-done :response response}))))) + +(rf/reg-event-fx + :wallet/clear-last-collectible-details + (fn [{:keys [db]}] + {:db (update-in db [:wallet] dissoc :last-collectible-details)})) diff --git a/src/status_im/contexts/wallet/home/tabs/view.cljs b/src/status_im/contexts/wallet/home/tabs/view.cljs index 95669b4b8f..e7c9428609 100644 --- a/src/status_im/contexts/wallet/home/tabs/view.cljs +++ b/src/status_im/contexts/wallet/home/tabs/view.cljs @@ -16,6 +16,5 @@ :collectibles [collectibles/view {:collectibles collectible-list :on-collectible-press (fn [{:keys [id]}] - (rf/dispatch [:wallet/get-collectible-details id]) - (rf/dispatch [:navigate-to :wallet-collectible]))}] + (rf/dispatch [:wallet/get-collectible-details id]))}] [activity/view])]))