fix bottom tabs unread badge for group chats (#17454)

This commit is contained in:
Parvesh Monu 2023-09-29 17:59:35 +05:30 committed by GitHub
parent bf76ca167a
commit 695bbcbe81
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 15 deletions

View File

@ -231,10 +231,18 @@
(update-in [:community-stack :unviewed-mentions-count] + unviewed-mentions-count))
(and (not muted)
(#{constants/private-group-chat-type constants/one-to-one-chat-type} chat-type))
(= chat-type constants/private-group-chat-type))
(-> acc
(update-in [:chats-stack :unviewed-messages-count] + unviewed-messages-count)
(update-in [:chats-stack :unviewed-mentions-count] + unviewed-mentions-count))
(and (not muted)
(= chat-type constants/one-to-one-chat-type))
;; Note - for 1-1 chats, all unread messages are counted as mentions and shown with counter
(-> acc
(update-in [:chats-stack :unviewed-messages-count] + unviewed-messages-count)
(update-in [:chats-stack :unviewed-mentions-count] + unviewed-messages-count))
:else
acc))
{:chats-stack {:unviewed-messages-count 0 :unviewed-mentions-count 0}
@ -248,8 +256,10 @@
:counter-label (:unviewed-mentions-count community-stack)}
:chats-stack
{:new-notifications? (pos? (:unviewed-messages-count chats-stack))
:notification-indicator :counter
:counter-label (:unviewed-messages-count chats-stack)}})))
:notification-indicator (if (pos? (:unviewed-mentions-count chats-stack))
:counter
:unread-dot)
:counter-label (:unviewed-mentions-count chats-stack)}})))
;; Floating screens
(re-frame/reg-sub

View File

@ -5,17 +5,10 @@
[cljs.test :refer [is testing]]
[status-im2.constants :as constants]))
(def expected-notification-data-for-public-profile-timeline-chats
{:communities-stack {:new-notifications? false
:notification-indicator :unread-dot
:counter-label 0}
:chats-stack {:new-notifications? false
:notification-indicator :unread-dot
:counter-label 0}})
;; Note - for 1-1 chats, all unread messages are counted as mentions and shown with counter
(def one-to-one-group-community-chats1
{"0xone-to-one-chat1" {:chat-type constants/one-to-one-chat-type
:unviewed-messages-count 5
:unviewed-messages-count 0
:unviewed-mentions-count 0}
"0xgroup-chat1" {:chat-type constants/private-group-chat-type
:unviewed-messages-count 2
@ -29,8 +22,8 @@
:notification-indicator :unread-dot
:counter-label 0}
:chats-stack {:new-notifications? true
:notification-indicator :counter
:counter-label 7}})
:notification-indicator :unread-dot
:counter-label 0}})
(def one-to-one-group-community-chats2
(merge
@ -51,7 +44,7 @@
:counter-label 7}
:chats-stack {:new-notifications? true
:notification-indicator :counter
:counter-label 19}})
:counter-label 11}})
(h/deftest-sub :shell/bottom-tabs-notifications-data
[sub-name]