From 297280c4671cf2c67d10bf4f9f20b64ded8f6cc7 Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Wed, 4 Jan 2023 13:29:30 -0500 Subject: [PATCH] fix(chat-badge): don't count unread messages when restarting Fixes #8943 --- src/app/modules/main/chat_section/module.nim | 2 +- src/app/modules/main/controller.nim | 6 ++++-- src/app/modules/main/module.nim | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/app/modules/main/chat_section/module.nim b/src/app/modules/main/chat_section/module.nim index d8c8368446..1705f37d2e 100644 --- a/src/app/modules/main/chat_section/module.nim +++ b/src/app/modules/main/chat_section/module.nim @@ -137,7 +137,7 @@ proc buildChatSectionUI( continue let hasNotification = not chatDto.muted and (chatDto.unviewedMessagesCount > 0 or chatDto.unviewedMentionsCount > 0) - let notificationsCount = if (chatDto.muted): 0 else: chatDto.unviewedMentionsCount + let notificationsCount = chatDto.unviewedMentionsCount var chatName = chatDto.name var chatImage = "" diff --git a/src/app/modules/main/controller.nim b/src/app/modules/main/controller.nim index 034c970a34..a6175b98cc 100644 --- a/src/app/modules/main/controller.nim +++ b/src/app/modules/main/controller.nim @@ -325,7 +325,8 @@ proc getNumOfNotificaitonsForChat*(self: Controller): tuple[unviewed:int, mentio if(chat.chatType == ChatType.CommunityChat): continue - result.unviewed += chat.unviewedMessagesCount + if not chat.muted: + result.unviewed += chat.unviewedMessagesCount result.mentions += chat.unviewedMentionsCount proc getNumOfNotificationsForCommunity*(self: Controller, communityId: string): tuple[unviewed:int, mentions:int] = @@ -336,7 +337,8 @@ proc getNumOfNotificationsForCommunity*(self: Controller, communityId: string): if(chat.communityId != communityId): continue - result.unviewed += chat.unviewedMessagesCount + if not chat.muted: + result.unviewed += chat.unviewedMessagesCount result.mentions += chat.unviewedMentionsCount proc setCurrentUserStatus*(self: Controller, status: StatusType) = diff --git a/src/app/modules/main/module.nim b/src/app/modules/main/module.nim index 888d68eaf5..9af9d2f140 100644 --- a/src/app/modules/main/module.nim +++ b/src/app/modules/main/module.nim @@ -223,7 +223,7 @@ proc createChannelGroupItem[T](self: Module[T], c: ChannelGroupDto): SectionItem mentionsCount = mentionsCount + receivedContactRequests.len let hasNotification = unviewedCount > 0 or mentionsCount > 0 - let notificationsCount = mentionsCount # we need to add here number of requests + let notificationsCount = mentionsCount let active = self.getActiveSectionId() == c.id # We must pass on if the current item section is currently active to keep that property as it is result = initItem( c.id,