From 32ddf81a5e3eaaffbd46f5b10b03ce9d48cfff71 Mon Sep 17 00:00:00 2001 From: Parvesh Monu Date: Wed, 21 Aug 2024 14:26:48 +0530 Subject: [PATCH] Rename utils.navigation to events-helper and add docstring to clarify namespace use case (#21093) --- src/status_im/common/data_confirmation_sheet/view.cljs | 6 +++--- .../navigation.cljs => status_im/common/events_helper.cljs} | 6 +++--- .../contexts/profile/settings/screens/messages/view.cljs | 4 ++-- .../contexts/profile/settings/screens/syncing/view.cljs | 4 ++-- .../contexts/settings/privacy_and_security/view.cljs | 4 ++-- .../contexts/wallet/swap/set_spending_cap/view.cljs | 4 ++-- src/status_im/contexts/wallet/swap/setup_swap/view.cljs | 4 ++-- 7 files changed, 16 insertions(+), 16 deletions(-) rename src/{utils/navigation.cljs => status_im/common/events_helper.cljs} (50%) diff --git a/src/status_im/common/data_confirmation_sheet/view.cljs b/src/status_im/common/data_confirmation_sheet/view.cljs index 1ae5731bc8..5e0e472163 100644 --- a/src/status_im/common/data_confirmation_sheet/view.cljs +++ b/src/status_im/common/data_confirmation_sheet/view.cljs @@ -3,14 +3,14 @@ [quo.core :as quo] [react-native.core :as rn] [status-im.common.data-confirmation-sheet.style :as style] + [status-im.common.events-helper :as events-helper] [utils.i18n :as i18n] - [utils.navigation :as navigation] [utils.re-frame :as rf])) (defn on-choice-callback [syncing-on-mobile-network?] (rf/dispatch [:network/set-syncing-on-mobile-network syncing-on-mobile-network?]) - (navigation/hide-bottom-sheet)) + (events-helper/hide-bottom-sheet)) (def on-wifi-only (partial on-choice-callback false)) (def on-mobile-and-wifi (partial on-choice-callback true)) @@ -19,7 +19,7 @@ [] (let [settings-drawer? (= (rf/sub [:view-id]) :screen/settings.syncing) syncing-on-mobile-network? (rf/sub [:profile/syncing-on-mobile-network?])] - (rn/use-mount navigation/dismiss-keyboard) + (rn/use-mount events-helper/dismiss-keyboard) [:<> [quo/text {:weight :semi-bold diff --git a/src/utils/navigation.cljs b/src/status_im/common/events_helper.cljs similarity index 50% rename from src/utils/navigation.cljs rename to src/status_im/common/events_helper.cljs index 16f67f7566..aa08d4b8c2 100644 --- a/src/utils/navigation.cljs +++ b/src/status_im/common/events_helper.cljs @@ -1,6 +1,6 @@ -(ns utils.navigation - "Prefer to declare in this namespace only reusable navigation functions that - aren't better suited in a particular bounded context." +(ns status-im.common.events-helper + "Provides highly reusable dispatch functions to ensure consistency and avoid duplication in managing various events, + including navigation and other actions that affect application behavior." (:require [utils.re-frame :as rf])) (defn navigate-back diff --git a/src/status_im/contexts/profile/settings/screens/messages/view.cljs b/src/status_im/contexts/profile/settings/screens/messages/view.cljs index 1425ede052..eece5ce4e6 100644 --- a/src/status_im/contexts/profile/settings/screens/messages/view.cljs +++ b/src/status_im/contexts/profile/settings/screens/messages/view.cljs @@ -2,8 +2,8 @@ (:require [quo.core :as quo] [react-native.core :as rn] + [status-im.common.events-helper :as events-helper] [utils.i18n :as i18n] - [utils.navigation :as navigation] [utils.re-frame :as rf])) (defn- open-blocked-users @@ -21,7 +21,7 @@ [quo/page-nav {:background :blur :icon-name :i/arrow-left - :on-press navigation/navigate-back}] + :on-press events-helper/navigate-back}] [quo/page-top {:title (i18n/label :t/messages)}] [quo/category {:label (i18n/label :t/contacts) diff --git a/src/status_im/contexts/profile/settings/screens/syncing/view.cljs b/src/status_im/contexts/profile/settings/screens/syncing/view.cljs index 6387835109..0436168397 100644 --- a/src/status_im/contexts/profile/settings/screens/syncing/view.cljs +++ b/src/status_im/contexts/profile/settings/screens/syncing/view.cljs @@ -2,8 +2,8 @@ (:require [quo.core :as quo] [status-im.common.data-confirmation-sheet.view :as data-confirmation-sheet] + [status-im.common.events-helper :as events-helper] [utils.i18n :as i18n] - [utils.navigation :as navigation] [utils.re-frame :as rf])) (defn- open-paired-devices-list @@ -26,7 +26,7 @@ [quo/page-nav {:background :blur :icon-name :i/arrow-left - :on-press navigation/navigate-back}] + :on-press events-helper/navigate-back}] [quo/page-top {:title (i18n/label :t/syncing)}] [quo/category {:data [{:title (i18n/label :t/sync-and-backup) diff --git a/src/status_im/contexts/settings/privacy_and_security/view.cljs b/src/status_im/contexts/settings/privacy_and_security/view.cljs index 909b84ab6a..4b24e5e115 100644 --- a/src/status_im/contexts/settings/privacy_and_security/view.cljs +++ b/src/status_im/contexts/settings/privacy_and_security/view.cljs @@ -5,11 +5,11 @@ [react-native.core :as rn] [react-native.platform :as platform] [react-native.safe-area :as safe-area] + [status-im.common.events-helper :as events-helper] [status-im.contexts.settings.privacy-and-security.profile-picture.view :as profile-picture.view] [status-im.contexts.settings.privacy-and-security.style :as style] [status-im.feature-flags :as ff] [utils.i18n :as i18n] - [utils.navigation :as navigation] [utils.re-frame :as rf])) (defn- setting-preview-privacy @@ -68,7 +68,7 @@ {:key :header :background :blur :icon-name :i/arrow-left - :on-press navigation/navigate-back}] + :on-press events-helper/navigate-back}] [quo/standard-title {:title (i18n/label :t/privacy-and-security) :container-style style/title-container diff --git a/src/status_im/contexts/wallet/swap/set_spending_cap/view.cljs b/src/status_im/contexts/wallet/swap/set_spending_cap/view.cljs index 8cc10826a1..ed13970d6d 100644 --- a/src/status_im/contexts/wallet/swap/set_spending_cap/view.cljs +++ b/src/status_im/contexts/wallet/swap/set_spending_cap/view.cljs @@ -4,13 +4,13 @@ [quo.foundations.resources :as resources] [quo.theme :as quo.theme] [react-native.core :as rn] + [status-im.common.events-helper :as events-helper] [status-im.common.floating-button-page.view :as floating-button-page] [status-im.common.standard-authentication.core :as standard-auth] [status-im.contexts.wallet.common.utils.external-links :as external-links] [status-im.contexts.wallet.swap.set-spending-cap.style :as style] [utils.address :as address-utils] [utils.i18n :as i18n] - [utils.navigation :as navigation] [utils.re-frame :as rf])) (defn- swap-title @@ -209,7 +209,7 @@ {:footer-container-padding 0 :header [quo/page-nav {:icon-name :i/close - :on-press navigation/navigate-back + :on-press events-helper/navigate-back :margin-top 8 :background :blur :accessibility-label :top-bar}] diff --git a/src/status_im/contexts/wallet/swap/setup_swap/view.cljs b/src/status_im/contexts/wallet/swap/setup_swap/view.cljs index 06eadb2834..1ae3df5d7e 100644 --- a/src/status_im/contexts/wallet/swap/setup_swap/view.cljs +++ b/src/status_im/contexts/wallet/swap/setup_swap/view.cljs @@ -2,11 +2,11 @@ (:require [quo.core :as quo] [react-native.core :as rn] [react-native.safe-area :as safe-area] + [status-im.common.events-helper :as events-helper] [status-im.contexts.wallet.common.account-switcher.view :as account-switcher] [status-im.contexts.wallet.common.utils :as utils] [status-im.contexts.wallet.swap.setup-swap.style :as style] [utils.i18n :as i18n] - [utils.navigation :as navigation] [utils.re-frame :as rf])) (defn- data-item @@ -65,7 +65,7 @@ (set-pay-value #(subs % 0 (dec (count %)))))] [rn/view {:style style/container} [account-switcher/view - {:on-press navigation/navigate-back + {:on-press events-helper/navigate-back :icon-name :i/arrow-left :margin-top (safe-area/get-top) :switcher-type :select-account}]