From ef5153f138237ae2f5fc5901180ed01d38e09f30 Mon Sep 17 00:00:00 2001 From: Parvesh Monu Date: Wed, 20 Mar 2024 20:26:57 +0530 Subject: [PATCH] fix incorrect unread counter is displayed when a message is removed (#19217) --- src/legacy/status_im/chat/models/message.cljs | 5 +---- src/status_im/contexts/chat/events.cljs | 12 ------------ 2 files changed, 1 insertion(+), 16 deletions(-) diff --git a/src/legacy/status_im/chat/models/message.cljs b/src/legacy/status_im/chat/models/message.cljs index 8031c9beb8..c90f509140 100644 --- a/src/legacy/status_im/chat/models/message.cljs +++ b/src/legacy/status_im/chat/models/message.cljs @@ -4,7 +4,6 @@ [legacy.status-im.chat.models.loading :as chat.loading] [legacy.status-im.data-store.messages :as data-store.messages] [legacy.status-im.utils.deprecated-types :as types] - [re-frame.core :as re-frame] [react-native.platform :as platform] [status-im.contexts.chat.messenger.messages.delete-message.events :as delete-message] [status-im.contexts.chat.messenger.messages.list.events :as message-list] @@ -135,9 +134,7 @@ message-id (:messageId removed-message)] (data-store.messages/mark-messages-seen chat-id [message-id] - #(re-frame/dispatch - [:chat/decrease-unviewed-count - chat-id %3])))) + nil))) removed-messages) remove-messages-fx (fn [{:keys [db]}] {:dispatch [:activity-center.notifications/fetch-unread-count]})] diff --git a/src/status_im/contexts/chat/events.cljs b/src/status_im/contexts/chat/events.cljs index 0d574b4ee4..fd99460691 100644 --- a/src/status_im/contexts/chat/events.cljs +++ b/src/status_im/contexts/chat/events.cljs @@ -243,18 +243,6 @@ (update :chats-home-list conj chat-id)) :dispatch [:chat/pop-to-root-and-navigate-to-chat chat-id]})) -(rf/defn decrease-unviewed-count - {:events [:chat/decrease-unviewed-count]} - [{:keys [db]} chat-id {:keys [count countWithMentions]}] - {:db (-> db - ;; There might be some other requests being fired, so we need to make sure the count has - ;; not been set to - ;; 0 in the meantime - (update-in [:chats chat-id :unviewed-messages-count] - #(max (- % count) 0)) - (update-in [:chats chat-id :unviewed-mentions-count] - #(max (- % countWithMentions) 0)))}) - (rf/defn start-chat "Start a chat, making sure it exists" {:events [:chat.ui/start-chat]}