Skip to content

Commit

Permalink
fix incorrect unread counter is displayed when a message is removed
Browse files Browse the repository at this point in the history
  • Loading branch information
Parveshdhull committed Mar 13, 2024
1 parent 2009199 commit 98e8fe7
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 16 deletions.
5 changes: 1 addition & 4 deletions src/legacy/status_im/chat/models/message.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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]})]
Expand Down
12 changes: 0 additions & 12 deletions src/status_im/contexts/chat/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -244,18 +244,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]}
Expand Down

0 comments on commit 98e8fe7

Please sign in to comment.