From fb58d7205ef171ea5fb9e080fe4d46d81b21f58e Mon Sep 17 00:00:00 2001 From: Parvesh Monu Date: Mon, 8 Jan 2024 19:59:01 +0530 Subject: [PATCH] Add dispatch-and-chill to navigation events (#18372) --- src/status_im/contexts/chat/actions/view.cljs | 9 +++++++-- src/status_im/contexts/onboarding/intro/view.cljs | 11 +++++++---- .../contexts/onboarding/new_to_status/view.cljs | 5 ++++- src/status_im/contexts/profile/profiles/view.cljs | 9 +++++++-- 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/src/status_im/contexts/chat/actions/view.cljs b/src/status_im/contexts/chat/actions/view.cljs index c93972f0c2..c1778e4573 100644 --- a/src/status_im/contexts/chat/actions/view.cljs +++ b/src/status_im/contexts/chat/actions/view.cljs @@ -1,6 +1,7 @@ (ns status-im.contexts.chat.actions.view (:require [quo.core :as quo] + [utils.debounce :as debounce] [utils.i18n :as i18n] [utils.re-frame :as rf])) @@ -22,10 +23,14 @@ :label (i18n/label :t/new-chat) :on-press (fn [] (rf/dispatch [:group-chat/clear-contacts]) - (rf/dispatch [:open-modal :start-a-new-chat]))} + (debounce/dispatch-and-chill + [:open-modal :start-a-new-chat] + 1000))} {:icon :i/add-user :accessibility-label :add-a-contact :label (i18n/label :t/add-a-contact) :sub-label (i18n/label :t/enter-a-chat-key) :add-divider? true - :on-press #(rf/dispatch [:open-modal :new-contact])}]]]) + :on-press #(debounce/dispatch-and-chill + [:open-modal :new-contact] + 1000)}]]]) diff --git a/src/status_im/contexts/onboarding/intro/view.cljs b/src/status_im/contexts/onboarding/intro/view.cljs index 2d6330210c..b814d10248 100644 --- a/src/status_im/contexts/onboarding/intro/view.cljs +++ b/src/status_im/contexts/onboarding/intro/view.cljs @@ -8,8 +8,7 @@ [status-im.contexts.onboarding.intro.style :as style] [status-im.contexts.syncing.scan-sync-code.view :as scan-sync-code] [utils.debounce :as debounce] - [utils.i18n :as i18n] - [utils.re-frame :as rf])) + [utils.i18n :as i18n])) (defn view [] @@ -29,7 +28,9 @@ :bottom-card {:on-press (fn [] (when-let [blur-show-fn @overlay/blur-show-fn-atom] (blur-show-fn)) - (rf/dispatch [:open-modal :new-to-status])) + (debounce/dispatch-and-chill + [:open-modal :new-to-status] + 1000)) :heading (i18n/label :t/new-to-status) :accessibility-label :new-to-status-button}} [quo/text @@ -41,7 +42,9 @@ {:style style/plain-text} (i18n/label :t/by-continuing-you-accept)] [quo/text - {:on-press #(rf/dispatch [:open-modal :privacy-policy]) + {:on-press #(debounce/dispatch-and-chill + [:open-modal :privacy-policy] + 1000) :style style/highlighted-text} (i18n/label :t/terms-of-service)]]] [overlay/view]]) diff --git a/src/status_im/contexts/onboarding/new_to_status/view.cljs b/src/status_im/contexts/onboarding/new_to_status/view.cljs index eb431fee4e..45528a65e1 100644 --- a/src/status_im/contexts/onboarding/new_to_status/view.cljs +++ b/src/status_im/contexts/onboarding/new_to_status/view.cljs @@ -8,6 +8,7 @@ [status-im.common.resources :as resources] [status-im.config :as config] [status-im.contexts.onboarding.new-to-status.style :as style] + [utils.debounce :as debounce] [utils.i18n :as i18n] [utils.re-frame :as rf])) @@ -30,7 +31,9 @@ (* 2 56) ;; two other list items (* 2 16) ;; spacing between items 220) ;; extra spacing (top bar) - :on-press #(rf/dispatch [:onboarding/navigate-to-create-profile])}] + :on-press #(debounce/dispatch-and-chill + [:onboarding/navigate-to-create-profile] + 1000)}] [rn/view {:style style/subtitle-container} [quo/text {:style style/subtitle diff --git a/src/status_im/contexts/profile/profiles/view.cljs b/src/status_im/contexts/profile/profiles/view.cljs index d5682b8f6a..5ddfd31fbd 100644 --- a/src/status_im/contexts/profile/profiles/view.cljs +++ b/src/status_im/contexts/profile/profiles/view.cljs @@ -13,6 +13,7 @@ [status-im.contexts.onboarding.common.background.view :as background] [status-im.contexts.profile.profiles.style :as style] [taoensso.timbre :as log] + [utils.debounce :as debounce] [utils.i18n :as i18n] [utils.re-frame :as rf] [utils.transforms :as transforms])) @@ -49,11 +50,15 @@ :on-press (fn [] (when @push-animation-fn-atom (@push-animation-fn-atom)) - (rf/dispatch [:open-modal :new-to-status])) + (debounce/dispatch-and-chill + [:open-modal :new-to-status] + 1000)) :accessibility-label :create-new-profile} {:icon :i/multi-profile :label (i18n/label :t/add-existing-status-profile) - :on-press #(rf/dispatch [:open-modal :sign-in]) + :on-press #(debounce/dispatch-and-chill + [:open-modal :sign-in] + 1000) :accessibility-label :multi-profile}]]]) (defn show-new-account-options