[#12494] Update unviewed messages counter on message deletion

This commit is contained in:
Roman Volosovskyi 2021-08-31 12:14:53 +03:00
parent e6c416c2c3
commit a818dd4a2a
No known key found for this signature in database
GPG Key ID: 0238A4B5ECEE70DE
2 changed files with 12 additions and 10 deletions

View File

@ -434,10 +434,12 @@
(fx/defn decrease-unviewed-count
{:events [:chat/decrease-unviewed-count]}
[{:keys [db]} chat-id unseen-messages]
{:db (update-in db [:chats chat-id :unviewed-messages-count]
(fn [count]
;; 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
(max (- count unseen-messages) 0)))})
[{: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)))})

View File

@ -2,7 +2,7 @@
"_comment": "DO NOT EDIT THIS FILE BY HAND. USE 'scripts/update-status-go.sh <tag>' instead",
"owner": "status-im",
"repo": "status-go",
"version": "v0.84.1",
"commit-sha1": "83394e0ed17265cb20ab3e56fe3de13ca4057267",
"src-sha256": "0xhg4n5i8ifv2z3vydi0878n6mv53cajmsr54fpaxqr4lvhrkzza"
"version": "v0.85.0",
"commit-sha1": "0c0e02e93af31207fedb04f98ae6161cd4bcb3df",
"src-sha256": "1dzx8f0gjn5kbwkrfidnfacvahw79p85ampmps57bp0yszvq4rnl"
}