fix incorrect unread counter is displayed when a message is removed (#19217)

This commit is contained in:
Parvesh Monu 2024-03-20 20:26:57 +05:30 committed by GitHub
parent 463e8a5eec
commit ef5153f138
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 1 additions and 16 deletions

View File

@ -4,7 +4,6 @@
[legacy.status-im.chat.models.loading :as chat.loading] [legacy.status-im.chat.models.loading :as chat.loading]
[legacy.status-im.data-store.messages :as data-store.messages] [legacy.status-im.data-store.messages :as data-store.messages]
[legacy.status-im.utils.deprecated-types :as types] [legacy.status-im.utils.deprecated-types :as types]
[re-frame.core :as re-frame]
[react-native.platform :as platform] [react-native.platform :as platform]
[status-im.contexts.chat.messenger.messages.delete-message.events :as delete-message] [status-im.contexts.chat.messenger.messages.delete-message.events :as delete-message]
[status-im.contexts.chat.messenger.messages.list.events :as message-list] [status-im.contexts.chat.messenger.messages.list.events :as message-list]
@ -135,9 +134,7 @@
message-id (:messageId removed-message)] message-id (:messageId removed-message)]
(data-store.messages/mark-messages-seen chat-id (data-store.messages/mark-messages-seen chat-id
[message-id] [message-id]
#(re-frame/dispatch nil)))
[:chat/decrease-unviewed-count
chat-id %3]))))
removed-messages) removed-messages)
remove-messages-fx (fn [{:keys [db]}] remove-messages-fx (fn [{:keys [db]}]
{:dispatch [:activity-center.notifications/fetch-unread-count]})] {:dispatch [:activity-center.notifications/fetch-unread-count]})]

View File

@ -243,18 +243,6 @@
(update :chats-home-list conj chat-id)) (update :chats-home-list conj chat-id))
:dispatch [:chat/pop-to-root-and-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]}
[{: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 (rf/defn start-chat
"Start a chat, making sure it exists" "Start a chat, making sure it exists"
{:events [:chat.ui/start-chat]} {:events [:chat.ui/start-chat]}