diff --git a/src/status_im/browser/core.cljs b/src/status_im/browser/core.cljs index 711ed3c78f..73efaf45d2 100644 --- a/src/status_im/browser/core.cljs +++ b/src/status_im/browser/core.cljs @@ -17,6 +17,7 @@ [status-im.utils.deprecated-types :as types] [status-im.utils.random :as random] [status-im2.constants :as constants] + [status-im2.contexts.chat.events :as chat.events] [status-im2.navigation.events :as navigation] [taoensso.timbre :as log] [utils.address :as address] @@ -310,6 +311,7 @@ {:browser-id (:browser-id browser)} :browser/screen-id :browser)} (navigation/pop-to-root :shell-stack) + (chat.events/close-chat) (navigation/change-tab :browser-stack) (update-browser browser) (resolve-url nil))))) diff --git a/src/status_im/group_chats/core.cljs b/src/status_im/group_chats/core.cljs index eafda2deee..ff4ec410fc 100644 --- a/src/status_im/group_chats/core.cljs +++ b/src/status_im/group_chats/core.cljs @@ -17,7 +17,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/pop-to-root-and-navigate-to-chat cofx chat-id nil))) (rf/defn handle-chat-removed {:events [:chat-removed]} @@ -80,7 +80,7 @@ {:events [:group-chats/create-from-link]} [cofx {:keys [chat-id invitation-admin chat-name]}] (if (get-in cofx [:db :chats chat-id]) - {:dispatch [:chat/navigate-to-chat chat-id]} + {:dispatch [:chat/pop-to-root-and-navigate-to-chat chat-id]} {:json-rpc/call [{:method "wakuext_createGroupChatFromInvitation" :params [chat-name chat-id invitation-admin] :js-response true diff --git a/src/status_im2/common/universal_links.cljs b/src/status_im2/common/universal_links.cljs index 821c6b5f1a..706feda151 100644 --- a/src/status_im2/common/universal_links.cljs +++ b/src/status_im2/common/universal_links.cljs @@ -69,7 +69,7 @@ (rf/defn handle-community-chat [cofx {:keys [chat-id]}] (log/info "universal-links: handling community chat" chat-id) - {:dispatch [:chat/navigate-to-chat chat-id]}) + {:dispatch [:chat/pop-to-root-and-navigate-to-chat chat-id]}) (rf/defn handle-view-profile [{:keys [db] :as cofx} {:keys [public-key ens-name]}] diff --git a/src/status_im2/contexts/chat/effects.cljs b/src/status_im2/contexts/chat/effects.cljs index 5904b997b2..a9168b0669 100644 --- a/src/status_im2/contexts/chat/effects.cljs +++ b/src/status_im2/contexts/chat/effects.cljs @@ -14,5 +14,5 @@ :key-uid (fn [stored-key-uid] (when (= stored-key-uid key-uid) - (rf/dispatch [:chat/navigate-to-chat chat-id + (rf/dispatch [:chat/pop-to-root-and-navigate-to-chat chat-id shell.constants/open-screen-without-animation]))))))))) diff --git a/src/status_im2/contexts/chat/events.cljs b/src/status_im2/contexts/chat/events.cljs index becdf52e61..10cac79319 100644 --- a/src/status_im2/contexts/chat/events.cljs +++ b/src/status_im2/contexts/chat/events.cljs @@ -208,8 +208,6 @@ [{db :db :as cofx} chat-id animation] (rf/merge cofx {: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) (force-close-chat chat-id) (fn [{:keys [db]}] @@ -218,6 +216,14 @@ #(when (group-chat? cofx chat-id) (loading/load-chat % chat-id)))) +(rf/defn pop-to-root-and-navigate-to-chat + {:events [:chat/pop-to-root-and-navigate-to-chat]} + [cofx chat-id animation] + (rf/merge + cofx + (navigation/pop-to-root :shell-stack) + (navigate-to-chat chat-id animation))) + (rf/defn handle-clear-history-response {:events [:chat/history-cleared]} [{:keys [db]} chat-id response] @@ -237,7 +243,7 @@ (assoc-in [:chats chat-id] chat) :always (update :chats-home-list conj chat-id)) - :dispatch [:chat/navigate-to-chat chat-id]})) + :dispatch [:chat/pop-to-root-and-navigate-to-chat chat-id]})) (rf/defn decrease-unviewed-count {:events [:chat/decrease-unviewed-count]} diff --git a/src/status_im2/contexts/shell/activity_center/notification/membership/view.cljs b/src/status_im2/contexts/shell/activity_center/notification/membership/view.cljs index cb127cbbee..df3817369b 100644 --- a/src/status_im2/contexts/shell/activity_center/notification/membership/view.cljs +++ b/src/status_im2/contexts/shell/activity_center/notification/membership/view.cljs @@ -14,7 +14,7 @@ [gesture/touchable-without-feedback {:on-press (fn [] (rf/dispatch [:hide-popover]) - (rf/dispatch [:chat/navigate-to-chat chat-id]))} + (rf/dispatch [:chat/pop-to-root-and-navigate-to-chat chat-id]))} child] child)) diff --git a/src/status_im2/contexts/shell/activity_center/notification/mentions/view.cljs b/src/status_im2/contexts/shell/activity_center/notification/mentions/view.cljs index bbc3b16f96..3b4c18b667 100644 --- a/src/status_im2/contexts/shell/activity_center/notification/mentions/view.cljs +++ b/src/status_im2/contexts/shell/activity_center/notification/mentions/view.cljs @@ -52,7 +52,7 @@ [gesture/touchable-without-feedback {:on-press (fn [] (rf/dispatch [:hide-popover]) - (rf/dispatch [:chat/navigate-to-chat chat-id]))} + (rf/dispatch [:chat/pop-to-root-and-navigate-to-chat chat-id]))} [quo/activity-log {:title (i18n/label :t/mention) :customization-color customization-color diff --git a/src/status_im2/contexts/shell/activity_center/notification/reply/view.cljs b/src/status_im2/contexts/shell/activity_center/notification/reply/view.cljs index 9db039d2d3..07a715128d 100644 --- a/src/status_im2/contexts/shell/activity_center/notification/reply/view.cljs +++ b/src/status_im2/contexts/shell/activity_center/notification/reply/view.cljs @@ -74,7 +74,7 @@ [gesture/touchable-without-feedback {:on-press (fn [] (rf/dispatch [:hide-popover]) - (rf/dispatch [:chat/navigate-to-chat chat-id]))} + (rf/dispatch [:chat/pop-to-root-and-navigate-to-chat chat-id]))} [quo/activity-log {:title (i18n/label :t/message-reply) :customization-color customization-color diff --git a/src/status_im2/navigation/events.cljs b/src/status_im2/navigation/events.cljs index b9ca8f514e..56e694fa9f 100644 --- a/src/status_im2/navigation/events.cljs +++ b/src/status_im2/navigation/events.cljs @@ -60,15 +60,12 @@ (rf/defn pop-to-root {:events [:pop-to-root]} [{:keys [db]} tab] - (merge - {:pop-to-root-fx tab - :db (-> db - (dissoc :shell/floating-screens) - (dissoc :shell/loaded-screens) - (assoc :view-id (or @shell.state/selected-stack-id :shell))) - :effects.shell/pop-to-root nil} - (when (:current-chat-id db) - {:dispatch-n [[:chat/close]]}))) + {:pop-to-root-fx tab + :db (-> db + (dissoc :shell/floating-screens) + (dissoc :shell/loaded-screens) + (assoc :view-id (or @shell.state/selected-stack-id :shell))) + :effects.shell/pop-to-root nil}) (rf/defn init-root {:events [:init-root]}