Skip to content

Commit

Permalink
fix(categories): fix category unread status
Browse files Browse the repository at this point in the history
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 #14219
  • Loading branch information
jrainville committed May 23, 2024
1 parent 341fcf0 commit 489ed2e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
10 changes: 7 additions & 3 deletions src/app/modules/main/chat_section/module.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
4 changes: 2 additions & 2 deletions src/app_service/service/chat/service.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -214,7 +214,7 @@ QtObject:
proc init*(self: Service) =
self.doConnect()

self.asyncGetActiveChat()
self.asyncGetActiveChats()

proc hasChannel*(self: Service, chatId: string): bool =
self.chats.hasKey(chatId)
Expand Down
3 changes: 2 additions & 1 deletion src/app_service/service/community/service.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 489ed2e

Please sign in to comment.