From 9a8354f783144d1e2983c84af4727210ba5ac1ab Mon Sep 17 00:00:00 2001 From: Parvesh Monu Date: Fri, 28 Apr 2023 20:52:34 +0530 Subject: [PATCH] Improve dissmiss all overlays (#15773) --- src/react_native/navigation.cljs | 4 ---- src/status_im2/common/toasts/events.cljs | 8 ++++++++ src/status_im2/navigation/core.cljs | 4 ---- src/status_im2/navigation/events.cljs | 16 +++++++++++----- 4 files changed, 19 insertions(+), 13 deletions(-) diff --git a/src/react_native/navigation.cljs b/src/react_native/navigation.cljs index a5c20687da..a41dfd05c9 100644 --- a/src/react_native/navigation.cljs +++ b/src/react_native/navigation.cljs @@ -41,10 +41,6 @@ [comp] (.catch (.dismissOverlay Navigation comp) #())) -(defn dissmiss-all-overlays - [] - (.catch (.dismissAllOverlays Navigation) #())) - (defn reg-app-launched-listener [handler] (.registerAppLaunchedListener ^js (.events ^js Navigation) handler)) diff --git a/src/status_im2/common/toasts/events.cljs b/src/status_im2/common/toasts/events.cljs index f1b5ed485b..ba5ae5544d 100644 --- a/src/status_im2/common/toasts/events.cljs +++ b/src/status_im2/common/toasts/events.cljs @@ -45,3 +45,11 @@ (update-in [:db :toasts] assoc :hide-toasts-timer-set true) (assoc :dispatch-later [{:ms 500 :dispatch [:toasts/hide-with-check]}])) effect)))) + +(rf/defn close-all-toasts + {:events [:toasts/close-all-toasts]} + [{:keys [db]}] + {:dispatch-n (reduce (fn [acc toast] + (conj acc [:toasts/close (key toast)])) + [] + (get-in db [:toasts :toasts]))}) diff --git a/src/status_im2/navigation/core.cljs b/src/status_im2/navigation/core.cljs index 9fe69df50b..a13a28d386 100644 --- a/src/status_im2/navigation/core.cljs +++ b/src/status_im2/navigation/core.cljs @@ -160,8 +160,6 @@ ;; OVERLAY (def dissmiss-overlay navigation/dissmiss-overlay) -(def dissmiss-all-overlays navigation/dissmiss-all-overlays) - (defn show-overlay ([comp] (show-overlay comp {})) ([comp opts] @@ -175,8 +173,6 @@ :overlay {:interceptTouchOutside true}} opts)}}))) -(re-frame/reg-fx :dissmiss-all-overlays-fx dissmiss-all-overlays) - ;; toast (navigation/register-component "toasts" (fn [] views/toasts) js/undefined) diff --git a/src/status_im2/navigation/events.cljs b/src/status_im2/navigation/events.cljs index 0ed4e3619f..cd9bdcd2ee 100644 --- a/src/status_im2/navigation/events.cljs +++ b/src/status_im2/navigation/events.cljs @@ -143,8 +143,14 @@ (rf/defn dismiss-all-overlays {:events [:dissmiss-all-overlays]} [{:keys [db]}] - {:dissmiss-all-overlays-fx nil - :db (-> db - (dissoc :popover/popover) - (dissoc :visibility-status-popover/popover) - (assoc-in [:bottom-sheet :hide?] true))}) + {:dispatch-n [[:hide-popover] + [:hide-visibility-status-popover] + [:hide-bottom-sheet] + [:bottom-sheet-hidden] + [:hide-wallet-connect-sheet] + [:hide-wallet-connect-success-sheet] + [:hide-wallet-connect-app-management-sheet] + [:hide-signing-sheet] + [:hide-select-acc-sheet] + [:bottom-sheet/hide-old-navigation-overlay] + [:toasts/close-all-toasts]]})