Skip to content

Commit

Permalink
Fix empty chat in opened on pressing hashtag in a community channel
Browse files Browse the repository at this point in the history
  • Loading branch information
Parveshdhull committed Dec 12, 2023
1 parent e5179d3 commit 88dc6a3
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 19 deletions.
2 changes: 2 additions & 0 deletions src/status_im/browser/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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)))))
Expand Down
4 changes: 2 additions & 2 deletions src/status_im/group_chats/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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]}
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/status_im2/common/universal_links.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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]}]
Expand Down
2 changes: 1 addition & 1 deletion src/status_im2/contexts/chat/effects.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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])))))))))
12 changes: 9 additions & 3 deletions src/status_im2/contexts/chat/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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]}]
Expand All @@ -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]
Expand All @@ -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]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 6 additions & 9 deletions src/status_im2/navigation/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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]}
Expand Down

0 comments on commit 88dc6a3

Please sign in to comment.