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 shell-navigation-disabled? false)
(def community-accounts-selection-enabled? false)

View File

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

View File

@ -7,7 +7,6 @@
[status-im.chat.models.loading :as loading]
[status-im.data-store.chats :as chats-store]
[status-im2.common.muting.helpers :refer [format-mute-till]]
[status-im2.config :as config]
[status-im2.constants :as constants]
[status-im2.contexts.chat.composer.link-preview.events :as link-preview]
status-im2.contexts.chat.effects
@ -168,7 +167,7 @@
(rf/defn close-chat
{:events [:chat/close]}
[{:keys [db] :as cofx} navigate-to-shell?]
[{:keys [db] :as cofx}]
(when-let [chat-id (:current-chat-id db)]
(chat.state/reset-visible-item)
(rf/merge cofx
@ -177,15 +176,7 @@
(dissoc :current-chat-id)
(assoc-in [:chat/inputs chat-id :focused?] false))
:effects.async-storage/set {:chat-id 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]]})))
:key-uid nil}})
(link-preview/reset-all)
(delete-for-me/sync-all)
(delete-message/send-all)
@ -219,7 +210,7 @@
{:dispatch [(if animation :shell/navigate-to :navigate-to) :chat chat-id animation]}
(when-not (#{:community :community-overview :shell} (:view-id db))
(navigation/pop-to-root :shell-stack))
(close-chat false)
(close-chat)
(force-close-chat chat-id)
(fn [{:keys [db]}]
{:db (assoc db :current-chat-id chat-id)})

View File

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

View File

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

View File

@ -9,7 +9,6 @@
[react-native.platform :as platform]
[react-native.reanimated :as reanimated]
[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.navigation.style :as style]
[status-im2.contexts.chat.messages.pin.banner.view :as pin.banner]
@ -116,10 +115,7 @@
:background :blur
:size 32
:accessibility-label :back-button
:on-press #(do
(when config/shell-navigation-disabled?
(rf/dispatch [:chat/close]))
(rf/dispatch [:navigate-back]))}
:on-press #(rf/dispatch [:navigate-back])}
back-icon]
[reanimated/view
{: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 -
;; https://github.com/status-im/status-mobile/issues/16595
[rn/keyboard-avoiding-view
{:style (style/keyboard-avoiding-container insets)
{:style style/keyboard-avoiding-container
:keyboard-vertical-offset (- (:bottom insets))}
[list.view/message-list-content-view

View File

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

View File

@ -1,6 +1,5 @@
(ns status-im2.contexts.shell.jump-to.effects
(:require
[status-im2.config :as config]
[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.state :as state]
@ -15,9 +14,8 @@
(rf/reg-fx :effects.shell/navigate-to-jump-to
(fn []
(animation/close-home-stack false)
(when-not config/shell-navigation-disabled?
(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`.
;; This might take some time. So don't directly merge the effect of `pop-to-root` and

View File

@ -2,7 +2,6 @@
(:require
[status-im.data-store.switcher-cards :as switcher-cards-store]
[status-im.utils.core :as utils]
[status-im2.config :as config]
[status-im2.constants :as constants]
[status-im2.contexts.shell.jump-to.constants :as shell.constants]
status-im2.contexts.shell.jump-to.effects
@ -66,19 +65,10 @@
(when card-data
(rf/merge
cofx
(merge
{:db (assoc-in
db
[:shell/switcher-cards (:card-id card-data)]
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)))))
(rf/defn close-switcher-card
@ -94,9 +84,6 @@
{:events [:shell/navigate-to-jump-to]}
[{:keys [db]}]
(let [open-floating-screens (shell.utils/open-floating-screens)]
(merge
(if config/shell-navigation-disabled?
{:pop-to-root-fx :shell-stack}
{:db
(cond-> db
@ -118,8 +105,8 @@
(assoc-in [:shell/floating-screens shell.constants/discover-communities-screen :animation]
shell.constants/close-screen-without-animation))
:dispatch [:set-view-id :shell]})
{:effects.shell/navigate-to-jump-to nil})))
:dispatch [:set-view-id :shell]
:effects.shell/navigate-to-jump-to nil}))
(rf/defn change-shell-status-bar-style
{:events [:change-shell-status-bar-style]}
@ -162,15 +149,8 @@
(not hidden-screen?)
(:current-chat-id db))
(conj [:chat/close]))})
(merge
{:db (assoc db :view-id 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}]}))))
:navigate-to go-to-view-id}))
(rf/defn shell-navigate-back
{:events [:shell/navigate-back]}

View File

@ -6,7 +6,6 @@
[react-native.platform :as platform]
[react-native.reanimated :as reanimated]
[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.state :as state]
[utils.re-frame :as rf]))
@ -120,8 +119,7 @@
;;; Navigation
(defn shell-navigation?
[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
[]

View File

@ -1,9 +1,7 @@
(ns status-im2.contexts.shell.jump-to.view
(:require
[quo.core :as quo]
re-frame.db
[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.components.bottom-tabs.view :as bottom-tabs]
[status-im2.contexts.shell.jump-to.components.floating-screens.view :as floating-screens]
@ -17,18 +15,12 @@
(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)
(or
chat-screen-open?
(seq open-floating-screens)))
(seq (utils/open-floating-screens)))
(do
(when chat-screen-open? (rf/dispatch [:chat/close]))
(rf/dispatch [:navigate-back])
true)
false)))
false))
(defn floating-button
[shared-values]
@ -53,8 +45,7 @@
[:f> bottom-tabs/f-bottom-tabs]
[:f> home-stack/f-home-stack]
[floating-button shared-values]
(when-not config/shell-navigation-disabled?
[floating-screens/view])]))
[floating-screens/view]]))
(defn shell-stack
[]

View File

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