fix(categories): fix category unread status

Part of #14886

The problem was that the ChatDto doesn't have a categoryID, so we need to use the CommunityChat.

I think before, the channel groups had the full chat info, but not we can't rely on that.

The CommunityChat/Chat alignment refactor will simplify all of that https://github.com/status-im/status-desktop/issues/14219
This commit is contained in:
Jonathan Rainville 2024-05-23 14:35:57 -04:00
parent 6a820c9e72
commit 9523e6b764
3 changed files with 11 additions and 6 deletions

View File

@ -597,9 +597,13 @@ proc updateBadgeNotifications(self: Module, chat: ChatDto, hasUnreadMessages: bo
if (self.chatContentModules.contains(chatId)):
self.chatContentModules[chatId].onNotificationsUpdated(hasUnreadMessages, unviewedMentionsCount)
if chat.categoryId != "":
let hasUnreadMessages = self.controller.categoryHasUnreadMessages(chat.communityId, chat.categoryId)
self.view.chatsModel().setCategoryHasUnreadMessages(chat.categoryId, hasUnreadMessages)
if self.isCommunity:
let myCommunity = self.controller.getMyCommunity()
let communityChat = myCommunity.getCommunityChat(chatId)
if communityChat.categoryId != "":
let hasUnreadMessages = self.controller.categoryHasUnreadMessages(communityChat.communityId, communityChat.categoryId)
self.view.chatsModel().setCategoryHasUnreadMessages(communityChat.categoryId, hasUnreadMessages)
self.updateParentBadgeNotifications()

View File

@ -181,7 +181,7 @@ QtObject:
var args = RpcResponseArgs(e)
discard self.processMessengerResponse(args.response)
proc asyncGetActiveChat*(self: Service) =
proc asyncGetActiveChats*(self: Service) =
let arg = AsyncGetActiveChatsTaskArg(
tptr: cast[ByteAddress](asyncGetActiveChatsTask),
vptr: cast[ByteAddress](self.vptr),
@ -213,7 +213,7 @@ QtObject:
proc init*(self: Service) =
self.doConnect()
self.asyncGetActiveChat()
self.asyncGetActiveChats()
proc hasChannel*(self: Service, chatId: string): bool =
self.chats.hasKey(chatId)

View File

@ -2424,6 +2424,7 @@ QtObject:
for chat in self.communities[communityId].chats:
if chat.categoryId != categoryId:
continue
if (not chat.muted and chat.unviewedMessagesCount > 0) or chat.unviewedMentionsCount > 0:
let chatDto = self.chatService.getChatById(chat.id)
if (not chatDto.muted and chatDto.unviewedMessagesCount > 0) or chatDto.unviewedMentionsCount > 0:
return true
return false