From 35b64f0483da62f8f0ef1dfdf616c8e050256c4b Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Wed, 3 Jul 2024 14:55:07 -0400 Subject: [PATCH] fix(muted): reevaluate section badge when unmuting (#15360) Fixes #11093 When unmuting a channel, reevaluate the section badge so that it appears if there were unread messages in that channel Also fixes an issue where the chat muted property was not set correctly in the cache after muting or unmuting --- src/app/modules/main/chat_section/controller.nim | 1 - src/app/modules/main/chat_section/module.nim | 1 + src/app_service/service/chat/service.nim | 10 ++++++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/app/modules/main/chat_section/controller.nim b/src/app/modules/main/chat_section/controller.nim index eb83bb76a1..da76d7ee51 100644 --- a/src/app/modules/main/chat_section/controller.nim +++ b/src/app/modules/main/chat_section/controller.nim @@ -132,7 +132,6 @@ proc init*(self: Controller) = let chat = self.chatService.getChatById(args.chatId) self.delegate.onMarkMessageAsUnread(chat) - self.events.on(chat_service.SIGNAL_CHAT_LEFT) do(e: Args): let args = chat_service.ChatArgs(e) self.delegate.onCommunityChannelDeletedOrChatLeft(args.chatId) diff --git a/src/app/modules/main/chat_section/module.nim b/src/app/modules/main/chat_section/module.nim index 2990881a87..3bbf1aedd4 100644 --- a/src/app/modules/main/chat_section/module.nim +++ b/src/app/modules/main/chat_section/module.nim @@ -948,6 +948,7 @@ method onCategoryUnmuted*(self: Module, categoryId: string) = method changeMutedOnChat*(self: Module, chatId: string, muted: bool) = self.view.chatsModel().changeMutedOnItemById(chatId, muted) + self.updateParentBadgeNotifications() proc changeCanPostValues*(self: Module, chatId: string, canPost, canView, canPostReactions, viewersCanPostReactions: bool) = self.view.chatsModel().changeCanPostValues(chatId, canPost, canView, canPostReactions, viewersCanPostReactions) diff --git a/src/app_service/service/chat/service.nim b/src/app_service/service/chat/service.nim index b3f5e6fbf0..e904e746ba 100644 --- a/src/app_service/service/chat/service.nim +++ b/src/app_service/service/chat/service.nim @@ -575,6 +575,11 @@ QtObject: error "error while mute chat ", msg return + # There is no response except an error, so we can just modify the chat ourselves + var chat = self.chats[chatID] + chat.muted = true + self.updateOrAddChat(chat) + self.events.emit(SIGNAL_CHAT_MUTED, ChatArgs(chatId: chatId)) except Exception as e: let errDesription = e.msg @@ -593,6 +598,11 @@ QtObject: error "error while unmute chat ", msg return + # There is no response except an error, so we can just modify the chat ourselves + var chat = self.chats[chatID] + chat.muted = false + self.updateOrAddChat(chat) + self.events.emit(SIGNAL_CHAT_UNMUTED, ChatArgs(chatId: chatId)) except Exception as e: let errDesription = e.msg