From 88dc6a34c73a8f4106cff9d990bba64d2446b48e Mon Sep 17 00:00:00 2001 From: Parvesh Monu Date: Thu, 7 Dec 2023 15:22:29 +0530 Subject: [PATCH] Fix empty chat in opened on pressing hashtag in a community channel --- src/status_im/browser/core.cljs | 2 ++ src/status_im/group_chats/core.cljs | 4 ++-- src/status_im2/common/universal_links.cljs | 2 +- src/status_im2/contexts/chat/effects.cljs | 2 +- src/status_im2/contexts/chat/events.cljs | 12 +++++++++--- .../notification/membership/view.cljs | 2 +- .../notification/mentions/view.cljs | 2 +- .../activity_center/notification/reply/view.cljs | 2 +- src/status_im2/navigation/events.cljs | 15 ++++++--------- 9 files changed, 24 insertions(+), 19 deletions(-) diff --git a/src/status_im/browser/core.cljs b/src/status_im/browser/core.cljs index 711ed3c78f64..001f9291b4b7 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 true) (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 eafda2deeea0..ff4ec410fca5 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 821c6b5f1a2d..706feda151f0 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 5904b997b2c6..a9168b066965 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 3dddcebb2fc6..583811fefb84 100644 --- a/src/status_im2/contexts/chat/events.cljs +++ b/src/status_im2/contexts/chat/events.cljs @@ -217,8 +217,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 false) (force-close-chat chat-id) (fn [{:keys [db]}] @@ -227,6 +225,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] @@ -246,7 +252,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 cb127cbbeed0..df3817369bb5 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 bbc3b16f9613..3b4c18b66788 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 9db039d2d357..07a715128d26 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 b9ca8f514e81..56e694fa9f79 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]}