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
This commit is contained in:
mmilad75 2024-02-20 15:04:33 +00:00 committed by GitHub
parent ae08cb161f
commit c7aa10c789
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 18 additions and 6 deletions

View File

@ -19,8 +19,7 @@
:collectibles [collectibles/view :collectibles [collectibles/view
{:collectibles collectible-list {:collectibles collectible-list
:on-collectible-press (fn [{:keys [id]}] :on-collectible-press (fn [{:keys [id]}]
(rf/dispatch [:wallet/get-collectible-details id]) (rf/dispatch [:wallet/get-collectible-details id]))}]
(rf/dispatch [:navigate-to :wallet-collectible]))}]
:activity [activity/view] :activity [activity/view]
:permissions [empty-tab/view :permissions [empty-tab/view
{:title (i18n/label :t/no-permissions) {:title (i18n/label :t/no-permissions)

View File

@ -99,7 +99,7 @@
:label (i18n/label :t/share-collectible) :label (i18n/label :t/share-collectible)
:right-icon :i/external}]]])) :right-icon :i/external}]]]))
(defn view-internal (defn f-view-internal
[{:keys [theme] :as _props}] [{:keys [theme] :as _props}]
(let [selected-tab (reagent/atom :overview) (let [selected-tab (reagent/atom :overview)
on-tab-change #(reset! selected-tab %)] on-tab-change #(reset! selected-tab %)]
@ -116,6 +116,10 @@
{collection-image :image-url {collection-image :image-url
collection-name :name} collection-data collection-name :name} collection-data
{collectible-name :name} collectible-data] {collectible-name :name} collectible-data]
(rn/use-effect
(fn []
#(rf/dispatch [:wallet/clear-last-collectible-details]))
[])
[scroll-page/scroll-page [scroll-page/scroll-page
{:navigate-back? true {:navigate-back? true
:height 148 :height 148
@ -177,4 +181,8 @@
:data tabs-data}] :data tabs-data}]
[tabs/view {:selected-tab @selected-tab}]]])))) [tabs/view {:selected-tab @selected-tab}]]]))))
(defn- view-internal
[props]
[:f> f-view-internal props])
(def view (quo.theme/with-theme view-internal)) (def view (quo.theme/with-theme view-internal))

View File

@ -56,7 +56,8 @@
(defn store-last-collectible-details (defn store-last-collectible-details
[{:keys [db]} [collectible]] [{: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) (rf/reg-event-fx :wallet/store-last-collectible-details store-last-collectible-details)
@ -126,3 +127,8 @@
(log/error "failed to get collectible details" (log/error "failed to get collectible details"
{:event :wallet/get-collectible-details-done {:event :wallet/get-collectible-details-done
:response response}))))) :response response})))))
(rf/reg-event-fx
:wallet/clear-last-collectible-details
(fn [{:keys [db]}]
{:db (update-in db [:wallet] dissoc :last-collectible-details)}))

View File

@ -16,6 +16,5 @@
:collectibles [collectibles/view :collectibles [collectibles/view
{:collectibles collectible-list {:collectibles collectible-list
:on-collectible-press (fn [{:keys [id]}] :on-collectible-press (fn [{:keys [id]}]
(rf/dispatch [:wallet/get-collectible-details id]) (rf/dispatch [:wallet/get-collectible-details id]))}]
(rf/dispatch [:navigate-to :wallet-collectible]))}]
[activity/view])])) [activity/view])]))