remove navigate-to-nav2 event (#15454)

This commit is contained in:
Parvesh Monu 2023-03-24 15:44:17 +05:30 committed by GitHub
parent 45da51bea6
commit 5c92b7eb1e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 59 additions and 68 deletions

View File

@ -276,7 +276,7 @@
(vals (get-in db [:communities community-id :chats])))]
(when (and id
(not= (:current-chat-id db) (str community-id id)))
(chat.events/navigate-to-chat cofx (str community-id id) nil))))
(chat.events/navigate-to-chat cofx (str community-id id)))))
(rf/defn fetch
[_]
@ -817,7 +817,7 @@
[cofx community-id]
(rf/merge cofx
(navigation/pop-to-root :shell-stack)
(navigation/navigate-to-nav2 :community community-id true)))
(navigation/navigate-to-cofx :community-overview community-id)))
(rf/defn member-role-updated
{:events [:community.member/role-updated]}

View File

@ -15,7 +15,7 @@
{:events [:navigate-chat-updated]}
[cofx chat-id]
(when (get-in cofx [:db :chats chat-id])
(chat.events/navigate-to-chat cofx chat-id nil)))
(chat.events/navigate-to-chat cofx chat-id)))
(rf/defn handle-chat-removed
{:events [:chat-removed]}

View File

@ -44,6 +44,7 @@
[status-im2.navigation.events :as navigation]
[status-im2.common.log :as logging]
[taoensso.timbre :as log]
[status-im2.contexts.shell.animation :as shell.animation]
[utils.security.core :as security]))
(re-frame/reg-fx
@ -520,6 +521,7 @@
tos-accepted? (get db :tos/accepted?)
{:networks/keys [current-network networks]} db
network-id (str (get-in networks [current-network :config :NetworkId]))]
(shell.animation/change-selected-stack-id :communities-stack true)
(rf/merge cofx
{:db (-> db
(dissoc :multiaccounts/login)

View File

@ -48,7 +48,7 @@
:on-press (fn []
(rf/dispatch [:communities/load-category-states id])
(rf/dispatch [:dismiss-keyboard])
(rf/dispatch [:navigate-to-nav2 :community {:community-id id}]))
(rf/dispatch [:navigate-to :community-overview id]))
:on-long-press #(rf/dispatch [:bottom-sheet/show-sheet
{:content (fn []
[community/community-actions community])}])}
@ -111,7 +111,7 @@
(i18n/label :t/open-membership))]]
:on-press #(do
(rf/dispatch [:dismiss-keyboard])
(rf/dispatch [:navigate-to-nav2 :community {:community-id id}]))}]))
(rf/dispatch [:navigate-to :community-overview id]))}]))
(defn communities-actions
[]

View File

@ -384,7 +384,7 @@
[rn/touchable-opacity
{:on-press #(re-frame/dispatch
[:communities/navigate-to-community
{:community-id (:id community)}])}
(:id community)])}
[rn/text
{:style {:text-align :center
:color quo.colors/blue}} (i18n/label :t/view)]]]])))

View File

@ -202,9 +202,9 @@
(rf/defn navigate-to-chat
"Takes coeffects map and chat-id, returns effects necessary for navigation and preloading data"
{:events [:chat/navigate-to-chat]}
[{db :db :as cofx} chat-id from-shell?]
[{db :db :as cofx} chat-id]
(rf/merge cofx
{:dispatch [:navigate-to-nav2 :chat chat-id from-shell?]}
{:dispatch [:navigate-to :chat chat-id]}
(when-not (or (= (:view-id db) :community) (= (:view-id db) :community-overview))
(navigation/pop-to-root :shell-stack))
(close-chat false)

View File

@ -88,7 +88,7 @@
(let [chat-id "test_chat"
db {:pagination-info {chat-id {:all-loaded? true}}}]
(testing "Pagination info should be reset on navigation"
(let [res (chat/navigate-to-chat {:db db} chat-id false)]
(let [res (chat/navigate-to-chat {:db db} chat-id)]
(is (nil? (get-in res [:db :pagination-info chat-id :all-loaded?])))))))
(deftest camera-roll-loading-more-test

View File

@ -34,7 +34,7 @@
{:on-press (fn []
(rf/dispatch [:communities/load-category-states (:id item)])
(rf/dispatch [:dismiss-keyboard])
(rf/dispatch [:navigate-to :community {:community-id (:id item)}]))
(rf/dispatch [:navigate-to :community-overview (:id item)]))
:on-long-press #(rf/dispatch
[:bottom-sheet/show-sheet
{:content (fn []
@ -144,7 +144,7 @@
{:on-press (fn []
(rf/dispatch [:communities/load-category-states (:id community)])
(rf/dispatch [:dismiss-keyboard])
(rf/dispatch [:navigate-to :community (:id community)]))
(rf/dispatch [:navigate-to :community-overview (:id community)]))
:on-long-press #(rf/dispatch [:bottom-sheet/show-sheet
{:content (fn []
;; TODO implement with quo2

View File

@ -18,7 +18,7 @@
item (merge item unviewed-counts)]
[quo/communities-membership-list-item
{:style {:padding-horizontal 18}
:on-press #(rf/dispatch [:navigate-to-nav2 :community-overview id])
:on-press #(rf/dispatch [:navigate-to :community-overview id])
:on-long-press #(rf/dispatch
[:bottom-sheet/show-sheet
{:content (fn []

View File

@ -26,6 +26,16 @@
(or (= state shell.constants/open-with-animation)
(= state shell.constants/open-without-animation))))
(defn calculate-home-stack-state-value
[stack-id & animate?]
(if animate?
(if (some? stack-id)
shell.constants/open-with-animation
shell.constants/close-with-animation)
(if (some? stack-id)
shell.constants/open-without-animation
shell.constants/close-without-animation)))
(defn load-stack
[stack-id]
(case stack-id
@ -35,14 +45,14 @@
:browser-stack (reset! load-browser-stack? true)
""))
(defn selected-stack-id-loaded
[stack-id]
(reset! selected-stack-id stack-id)
(reset!
home-stack-state
(if (some? stack-id)
shell.constants/open-with-animation
shell.constants/close-with-animation)))
(defn change-selected-stack-id
[stack-id & [store? home-stack-state-value]]
(let [home-stack-state-value (or home-stack-state-value
(calculate-home-stack-state-value stack-id))]
(reset! selected-stack-id stack-id)
(reset! home-stack-state home-stack-state-value)
(when store?
(async-storage/set-item! :selected-stack-id stack-id))))
(defn calculate-home-stack-position
[]
@ -133,28 +143,17 @@
(defn open-home-stack
[stack-id animate?]
(let [home-stack-state-value (if animate?
shell.constants/open-with-animation
shell.constants/open-without-animation)]
(reanimated/set-shared-value
(:selected-stack-id @shared-values-atom)
(name stack-id))
(reanimated/set-shared-value
(:home-stack-state @shared-values-atom)
home-stack-state-value)
(reset! home-stack-state home-stack-state-value)
(js/setTimeout
change-root-status-bar-style
shell.constants/shell-animation-time)
(reset! selected-stack-id stack-id)
(async-storage/set-item! :selected-stack-id stack-id)))
(let [home-stack-state-value (calculate-home-stack-state-value stack-id animate?)]
(reanimated/set-shared-value (:selected-stack-id @shared-values-atom) (name stack-id))
(reanimated/set-shared-value (:home-stack-state @shared-values-atom) home-stack-state-value)
(js/setTimeout change-root-status-bar-style shell.constants/shell-animation-time)
(change-selected-stack-id stack-id true home-stack-state-value)))
(defn change-tab
[stack-id]
(reanimated/set-shared-value (:animate-home-stack-left @shared-values-atom) false)
(reanimated/set-shared-value (:selected-stack-id @shared-values-atom) (name stack-id))
(reset! selected-stack-id stack-id)
(async-storage/set-item! :selected-stack-id stack-id))
(change-selected-stack-id stack-id true))
(defn bottom-tab-on-press
[stack-id]
@ -169,16 +168,9 @@
(defn close-home-stack
[animate?]
(let [home-stack-state-value (if animate?
shell.constants/close-with-animation
shell.constants/close-without-animation)]
(reanimated/set-shared-value
(:animate-home-stack-left @shared-values-atom)
true)
(reanimated/set-shared-value
(:home-stack-state @shared-values-atom)
home-stack-state-value)
(reset! home-stack-state home-stack-state-value)
(let [stack-id nil
home-stack-state-value (calculate-home-stack-state-value stack-id animate?)]
(reanimated/set-shared-value (:animate-home-stack-left @shared-values-atom) true)
(reanimated/set-shared-value (:home-stack-state @shared-values-atom) home-stack-state-value)
(change-root-status-bar-style)
(reset! selected-stack-id nil)
(async-storage/set-item! :selected-stack-id nil)))
(change-selected-stack-id stack-id true home-stack-state-value)))

View File

@ -42,7 +42,7 @@
(utils.universal-links/initialize)
;; TODO(parvesh) - Remove while moving functionality to status-go
(async-storage/get-item :selected-stack-id #(animation/selected-stack-id-loaded %))
(async-storage/get-item :selected-stack-id #(animation/change-selected-stack-id %))
(async-storage/get-item :screen-height #(reset! animation/screen-height %))

View File

@ -11,11 +11,16 @@
(assoc-in [:navigation/screen-params view] screen-params)))
(rf/defn navigate-to-cofx
[{:keys [db]} go-to-view-id screen-params]
{:db
(-> (assoc db :view-id go-to-view-id)
(all-screens-params go-to-view-id screen-params))
:navigate-to-fx go-to-view-id})
[{:keys [db] :as cofx} go-to-view-id screen-params]
(merge
{:db (-> (assoc db :view-id go-to-view-id)
(all-screens-params go-to-view-id screen-params))
:navigate-to-fx go-to-view-id}
(when (#{: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 navigate-to
{:events [:navigate-to]}
@ -100,14 +105,6 @@
{:shell/reset-bottom-tabs nil
:dispatch [:init-root :shell-stack]})
(rf/defn navigate-to-nav2
{:events [:navigate-to-nav2]}
[cofx view-id screen-params from-shell?]
(rf/merge
cofx
{:dispatch [:shell/add-switcher-card view-id screen-params from-shell?]}
(navigate-to-cofx view-id screen-params)))
(rf/defn change-root-status-bar-style
{:events [:change-root-status-bar-style]}
[_ style]

View File

@ -67,7 +67,7 @@
(str profile-picture "&addRing=0"))}
:customization-color (or (:customization-color contact) :primary)
:on-close #(re-frame/dispatch [:shell/close-switcher-card id])
:on-press #(re-frame/dispatch [:chat/navigate-to-chat id true])
:on-press #(re-frame/dispatch [:chat/navigate-to-chat id])
:content (get-card-content chat communities)}))
(defn private-group-chat-card
@ -76,7 +76,7 @@
:avatar-params {}
:customization-color (or (:customization-color chat) :primary)
:on-close #(re-frame/dispatch [:shell/close-switcher-card id])
:on-press #(re-frame/dispatch [:chat/navigate-to-chat id true])
:on-press #(re-frame/dispatch [:chat/navigate-to-chat id])
:content (get-card-content chat communities)})
(defn community-card
@ -88,7 +88,7 @@
{:name (:name community)})
:customization-color (or (:customization-color community) :primary)
:on-close #(re-frame/dispatch [:shell/close-switcher-card id])
:on-press #(re-frame/dispatch [:navigate-to-nav2 :community-overview id true])
:on-press #(re-frame/dispatch [:navigate-to :community-overview id])
:content {:community-info {:type :permission}}}))
(defn community-channel-card
@ -98,9 +98,9 @@
{:content {:community-channel {:emoji (:emoji channel)
:channel-name (str "# " (:name channel))}}
:on-press (fn []
(re-frame/dispatch [:navigate-to-nav2 :community-overview community-id true])
(re-frame/dispatch [:navigate-to :community-overview community-id])
(js/setTimeout
#(re-frame/dispatch [:chat/navigate-to-chat channel-id true])
#(re-frame/dispatch [:chat/navigate-to-chat channel-id])
100))}))
(re-frame/reg-sub