Remove toggle for disabling shell navigation

This commit is contained in:
Parvesh Monu 2023-12-12 17:55:29 +05:30 committed by GitHub
parent e5179d308b
commit 0dd63490f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 44 additions and 112 deletions

View File

@ -157,6 +157,4 @@
(def default-kdf-iterations 3200) (def default-kdf-iterations 3200)
(def shell-navigation-disabled? false)
(def community-accounts-selection-enabled? false) (def community-accounts-selection-enabled? false)

View File

@ -4,7 +4,6 @@
[react-native.blur :as blur] [react-native.blur :as blur]
[react-native.core :as rn] [react-native.core :as rn]
[react-native.reanimated :as reanimated] [react-native.reanimated :as reanimated]
[status-im2.config :as config]
[status-im2.contexts.chat.composer.style :as style] [status-im2.contexts.chat.composer.style :as style]
[utils.i18n :as i18n] [utils.i18n :as i18n]
[utils.re-frame :as rf])) [utils.re-frame :as rf]))
@ -40,8 +39,6 @@
[quo/floating-shell-button [quo/floating-shell-button
{:jump-to {:jump-to
{:on-press (fn [] {:on-press (fn []
(when config/shell-navigation-disabled?
(rf/dispatch [:chat/close true]))
(rf/dispatch [:shell/navigate-to-jump-to])) (rf/dispatch [:shell/navigate-to-jump-to]))
:customization-color customization-color :customization-color customization-color
:label (i18n/label :t/jump-to) :label (i18n/label :t/jump-to)

View File

@ -7,7 +7,6 @@
[status-im.chat.models.loading :as loading] [status-im.chat.models.loading :as loading]
[status-im.data-store.chats :as chats-store] [status-im.data-store.chats :as chats-store]
[status-im2.common.muting.helpers :refer [format-mute-till]] [status-im2.common.muting.helpers :refer [format-mute-till]]
[status-im2.config :as config]
[status-im2.constants :as constants] [status-im2.constants :as constants]
[status-im2.contexts.chat.composer.link-preview.events :as link-preview] [status-im2.contexts.chat.composer.link-preview.events :as link-preview]
status-im2.contexts.chat.effects status-im2.contexts.chat.effects
@ -168,7 +167,7 @@
(rf/defn close-chat (rf/defn close-chat
{:events [:chat/close]} {:events [:chat/close]}
[{:keys [db] :as cofx} navigate-to-shell?] [{:keys [db] :as cofx}]
(when-let [chat-id (:current-chat-id db)] (when-let [chat-id (:current-chat-id db)]
(chat.state/reset-visible-item) (chat.state/reset-visible-item)
(rf/merge cofx (rf/merge cofx
@ -177,15 +176,7 @@
(dissoc :current-chat-id) (dissoc :current-chat-id)
(assoc-in [:chat/inputs chat-id :focused?] false)) (assoc-in [:chat/inputs chat-id :focused?] false))
:effects.async-storage/set {:chat-id nil :effects.async-storage/set {:chat-id nil
:key-uid nil}} :key-uid nil}})
(let [community-id (get-in db [:chats chat-id :community-id])]
;; When navigating back from community chat to community, update switcher card
;; A close chat event is also called while opening any chat.
;; That might lead to duplicate :dispatch keys in fx/merge, that's why dispatch-n
;; is used here.
(when (and community-id config/shell-navigation-disabled? (not navigate-to-shell?))
{:dispatch-n [[:shell/add-switcher-card
:community-overview community-id]]})))
(link-preview/reset-all) (link-preview/reset-all)
(delete-for-me/sync-all) (delete-for-me/sync-all)
(delete-message/send-all) (delete-message/send-all)
@ -219,7 +210,7 @@
{:dispatch [(if animation :shell/navigate-to :navigate-to) :chat chat-id animation]} {:dispatch [(if animation :shell/navigate-to :navigate-to) :chat chat-id animation]}
(when-not (#{:community :community-overview :shell} (:view-id db)) (when-not (#{:community :community-overview :shell} (:view-id db))
(navigation/pop-to-root :shell-stack)) (navigation/pop-to-root :shell-stack))
(close-chat false) (close-chat)
(force-close-chat chat-id) (force-close-chat chat-id)
(fn [{:keys [db]}] (fn [{:keys [db]}]
{:db (assoc db :current-chat-id chat-id)}) {:db (assoc db :current-chat-id chat-id)})

View File

@ -2,7 +2,6 @@
(:require (:require
[quo.core :as quo] [quo.core :as quo]
[react-native.core :as rn] [react-native.core :as rn]
[status-im2.config :as config]
[status-im2.constants :as constants] [status-im2.constants :as constants]
[status-im2.contexts.shell.jump-to.constants :as jump-to.constants] [status-im2.contexts.shell.jump-to.constants :as jump-to.constants]
[utils.i18n :as i18n] [utils.i18n :as i18n]
@ -40,8 +39,6 @@
[quo/floating-shell-button [quo/floating-shell-button
{:jump-to {:jump-to
{:on-press (fn [] {:on-press (fn []
(when config/shell-navigation-disabled?
(rf/dispatch [:chat/close true]))
(rf/dispatch [:shell/navigate-to-jump-to])) (rf/dispatch [:shell/navigate-to-jump-to]))
:customization-color customization-color :customization-color customization-color
:label (i18n/label :t/jump-to)}} :label (i18n/label :t/jump-to)}}

View File

@ -1,19 +1,14 @@
(ns status-im2.contexts.chat.messages.list.style (ns status-im2.contexts.chat.messages.list.style
(:require (:require
[quo.foundations.colors :as colors] [quo.foundations.colors :as colors]
[react-native.reanimated :as reanimated] [react-native.reanimated :as reanimated]))
[status-im2.config :as config]))
(defonce ^:const cover-height 168) (defonce ^:const cover-height 168)
(defonce ^:const overscroll-cover-height 2000) (defonce ^:const overscroll-cover-height 2000)
(defonce ^:const header-avatar-top-offset -36) (defonce ^:const header-avatar-top-offset -36)
(defn keyboard-avoiding-container (def keyboard-avoiding-container
[{:keys [top]}] {:flex 1})
{:position :relative
:flex 1
:top (if config/shell-navigation-disabled? (- top) 0)
:margin-bottom (if config/shell-navigation-disabled? (- top) 0)})
(def list-container (def list-container
{:padding-vertical 16}) {:padding-vertical 16})

View File

@ -9,7 +9,6 @@
[react-native.platform :as platform] [react-native.platform :as platform]
[react-native.reanimated :as reanimated] [react-native.reanimated :as reanimated]
[status-im2.common.home.actions.view :as actions] [status-im2.common.home.actions.view :as actions]
[status-im2.config :as config]
[status-im2.contexts.chat.messages.list.view :refer [topbar-invisible-scroll-y-value]] [status-im2.contexts.chat.messages.list.view :refer [topbar-invisible-scroll-y-value]]
[status-im2.contexts.chat.messages.navigation.style :as style] [status-im2.contexts.chat.messages.navigation.style :as style]
[status-im2.contexts.chat.messages.pin.banner.view :as pin.banner] [status-im2.contexts.chat.messages.pin.banner.view :as pin.banner]
@ -116,10 +115,7 @@
:background :blur :background :blur
:size 32 :size 32
:accessibility-label :back-button :accessibility-label :back-button
:on-press #(do :on-press #(rf/dispatch [:navigate-back])}
(when config/shell-navigation-disabled?
(rf/dispatch [:chat/close]))
(rf/dispatch [:navigate-back]))}
back-icon] back-icon]
[reanimated/view [reanimated/view
{:style (style/animated-header all-loaded? translate-animation title-opacity-animation)} {:style (style/animated-header all-loaded? translate-animation title-opacity-animation)}

View File

@ -49,7 +49,7 @@
;; Note - Don't pass `behavior :height` to keyboard avoiding view,. It breaks composer - ;; Note - Don't pass `behavior :height` to keyboard avoiding view,. It breaks composer -
;; https://github.com/status-im/status-mobile/issues/16595 ;; https://github.com/status-im/status-mobile/issues/16595
[rn/keyboard-avoiding-view [rn/keyboard-avoiding-view
{:style (style/keyboard-avoiding-container insets) {:style style/keyboard-avoiding-container
:keyboard-vertical-offset (- (:bottom insets))} :keyboard-vertical-offset (- (:bottom insets))}
[list.view/message-list-content-view [list.view/message-list-content-view

View File

@ -5,7 +5,6 @@
[quo.foundations.colors :as colors] [quo.foundations.colors :as colors]
[react-native.core :as rn] [react-native.core :as rn]
[react-native.fast-image :as fast-image] [react-native.fast-image :as fast-image]
[status-im2.config :as config]
[status-im2.constants :as constants] [status-im2.constants :as constants]
[status-im2.contexts.chat.messages.resolver.message-resolver :as resolver] [status-im2.contexts.chat.messages.resolver.message-resolver :as resolver]
[status-im2.contexts.shell.jump-to.animation :as animation] [status-im2.contexts.shell.jump-to.animation :as animation]
@ -198,13 +197,7 @@
(rf/dispatch [:chat/navigate-to-chat id]) (rf/dispatch [:chat/navigate-to-chat id])
(= card-type shell.constants/community-channel-card) (= card-type shell.constants/community-channel-card)
(if config/shell-navigation-disabled? (rf/dispatch [:chat/navigate-to-chat channel-id])
(do
(rf/dispatch [:navigate-to :community-overview id])
(js/setTimeout
#(rf/dispatch [:chat/navigate-to-chat channel-id])
100))
(rf/dispatch [:chat/navigate-to-chat channel-id]))
(= card-type shell.constants/community-card) (= card-type shell.constants/community-card)
(rf/dispatch [:navigate-to :community-overview id]))) (rf/dispatch [:navigate-to :community-overview id])))

View File

@ -1,6 +1,5 @@
(ns status-im2.contexts.shell.jump-to.effects (ns status-im2.contexts.shell.jump-to.effects
(:require (:require
[status-im2.config :as config]
[status-im2.contexts.shell.jump-to.animation :as animation] [status-im2.contexts.shell.jump-to.animation :as animation]
[status-im2.contexts.shell.jump-to.constants :as shell.constants] [status-im2.contexts.shell.jump-to.constants :as shell.constants]
[status-im2.contexts.shell.jump-to.state :as state] [status-im2.contexts.shell.jump-to.state :as state]
@ -15,9 +14,8 @@
(rf/reg-fx :effects.shell/navigate-to-jump-to (rf/reg-fx :effects.shell/navigate-to-jump-to
(fn [] (fn []
(animation/close-home-stack false) (animation/close-home-stack false)
(when-not config/shell-navigation-disabled?
(some-> ^js @state/jump-to-list-ref (some-> ^js @state/jump-to-list-ref
(.scrollToOffset #js {:y 0 :animated false}))))) (.scrollToOffset #js {:y 0 :animated false}))))
;; Note - pop-to-root resets currently opened screens to `close-screen-without-animation`. ;; Note - pop-to-root resets currently opened screens to `close-screen-without-animation`.
;; This might take some time. So don't directly merge the effect of `pop-to-root` and ;; This might take some time. So don't directly merge the effect of `pop-to-root` and

View File

@ -2,7 +2,6 @@
(:require (:require
[status-im.data-store.switcher-cards :as switcher-cards-store] [status-im.data-store.switcher-cards :as switcher-cards-store]
[status-im.utils.core :as utils] [status-im.utils.core :as utils]
[status-im2.config :as config]
[status-im2.constants :as constants] [status-im2.constants :as constants]
[status-im2.contexts.shell.jump-to.constants :as shell.constants] [status-im2.contexts.shell.jump-to.constants :as shell.constants]
status-im2.contexts.shell.jump-to.effects status-im2.contexts.shell.jump-to.effects
@ -66,19 +65,10 @@
(when card-data (when card-data
(rf/merge (rf/merge
cofx cofx
(merge
{:db (assoc-in {:db (assoc-in
db db
[:shell/switcher-cards (:card-id card-data)] [:shell/switcher-cards (:card-id card-data)]
switcher-card)} switcher-card)}
(when config/shell-navigation-disabled?
{:effects.shell/change-tab (cond
(#{shell.constants/one-to-one-chat-card
shell.constants/private-group-chat-card}
card-type)
:chats-stack
:else :communities-stack)}))
(switcher-cards-store/upsert-switcher-card-rpc switcher-card))))) (switcher-cards-store/upsert-switcher-card-rpc switcher-card)))))
(rf/defn close-switcher-card (rf/defn close-switcher-card
@ -94,9 +84,6 @@
{:events [:shell/navigate-to-jump-to]} {:events [:shell/navigate-to-jump-to]}
[{:keys [db]}] [{:keys [db]}]
(let [open-floating-screens (shell.utils/open-floating-screens)] (let [open-floating-screens (shell.utils/open-floating-screens)]
(merge
(if config/shell-navigation-disabled?
{:pop-to-root-fx :shell-stack}
{:db {:db
(cond-> db (cond-> db
@ -118,8 +105,8 @@
(assoc-in [:shell/floating-screens shell.constants/discover-communities-screen :animation] (assoc-in [:shell/floating-screens shell.constants/discover-communities-screen :animation]
shell.constants/close-screen-without-animation)) shell.constants/close-screen-without-animation))
:dispatch [:set-view-id :shell]}) :dispatch [:set-view-id :shell]
{:effects.shell/navigate-to-jump-to nil}))) :effects.shell/navigate-to-jump-to nil}))
(rf/defn change-shell-status-bar-style (rf/defn change-shell-status-bar-style
{:events [:change-shell-status-bar-style]} {:events [:change-shell-status-bar-style]}
@ -162,15 +149,8 @@
(not hidden-screen?) (not hidden-screen?)
(:current-chat-id db)) (:current-chat-id db))
(conj [:chat/close]))}) (conj [:chat/close]))})
(merge
{:db (assoc db :view-id go-to-view-id) {:db (assoc db :view-id go-to-view-id)
:navigate-to go-to-view-id} :navigate-to go-to-view-id}))
(when (and config/shell-navigation-disabled?
(#{:chat :community-overview} go-to-view-id))
{:dispatch-later
;; 300 ms delay because, navigation is priority over shell card update
[{:dispatch [:shell/add-switcher-card go-to-view-id screen-params]
:ms 300}]}))))
(rf/defn shell-navigate-back (rf/defn shell-navigate-back
{:events [:shell/navigate-back]} {:events [:shell/navigate-back]}

View File

@ -6,7 +6,6 @@
[react-native.platform :as platform] [react-native.platform :as platform]
[react-native.reanimated :as reanimated] [react-native.reanimated :as reanimated]
[react-native.safe-area :as safe-area] [react-native.safe-area :as safe-area]
[status-im2.config :as config]
[status-im2.contexts.shell.jump-to.constants :as shell.constants] [status-im2.contexts.shell.jump-to.constants :as shell.constants]
[status-im2.contexts.shell.jump-to.state :as state] [status-im2.contexts.shell.jump-to.state :as state]
[utils.re-frame :as rf])) [utils.re-frame :as rf]))
@ -120,8 +119,7 @@
;;; Navigation ;;; Navigation
(defn shell-navigation? (defn shell-navigation?
[view-id] [view-id]
(when-not config/shell-navigation-disabled? (some #{view-id} shell.constants/floating-screens))
(some #{view-id} shell.constants/floating-screens)))
(defn calculate-view-id (defn calculate-view-id
[] []

View File

@ -1,9 +1,7 @@
(ns status-im2.contexts.shell.jump-to.view (ns status-im2.contexts.shell.jump-to.view
(:require (:require
[quo.core :as quo] [quo.core :as quo]
re-frame.db
[react-native.core :as rn] [react-native.core :as rn]
[status-im2.config :as config]
[status-im2.contexts.shell.jump-to.animation :as animation] [status-im2.contexts.shell.jump-to.animation :as animation]
[status-im2.contexts.shell.jump-to.components.bottom-tabs.view :as bottom-tabs] [status-im2.contexts.shell.jump-to.components.bottom-tabs.view :as bottom-tabs]
[status-im2.contexts.shell.jump-to.components.floating-screens.view :as floating-screens] [status-im2.contexts.shell.jump-to.components.floating-screens.view :as floating-screens]
@ -17,18 +15,12 @@
(defn navigate-back-handler (defn navigate-back-handler
[] []
(let [chat-screen-open? (and config/shell-navigation-disabled?
(= (get @re-frame.db/app-db :view-id) :chat))
open-floating-screens (utils/open-floating-screens)]
(if (and (not @navigation.state/curr-modal) (if (and (not @navigation.state/curr-modal)
(or (seq (utils/open-floating-screens)))
chat-screen-open?
(seq open-floating-screens)))
(do (do
(when chat-screen-open? (rf/dispatch [:chat/close]))
(rf/dispatch [:navigate-back]) (rf/dispatch [:navigate-back])
true) true)
false))) false))
(defn floating-button (defn floating-button
[shared-values] [shared-values]
@ -53,8 +45,7 @@
[:f> bottom-tabs/f-bottom-tabs] [:f> bottom-tabs/f-bottom-tabs]
[:f> home-stack/f-home-stack] [:f> home-stack/f-home-stack]
[floating-button shared-values] [floating-button shared-values]
(when-not config/shell-navigation-disabled? [floating-screens/view]]))
[floating-screens/view])]))
(defn shell-stack (defn shell-stack
[] []

View File

@ -2,7 +2,6 @@
(:require (:require
[re-frame.core :as re-frame] [re-frame.core :as re-frame]
[status-im2.common.resources :as resources] [status-im2.common.resources :as resources]
[status-im2.config :as config]
[status-im2.constants :as constants] [status-im2.constants :as constants]
[status-im2.contexts.shell.jump-to.constants :as shell.constants] [status-im2.contexts.shell.jump-to.constants :as shell.constants]
[utils.datetime :as datetime] [utils.datetime :as datetime]
@ -269,5 +268,4 @@
:shell/chat-screen-loaded? :shell/chat-screen-loaded?
:<- [:shell/loaded-screens] :<- [:shell/loaded-screens]
(fn [screens] (fn [screens]
(or config/shell-navigation-disabled? (get screens shell.constants/chat-screen)))
(get screens shell.constants/chat-screen))))