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
This commit is contained in:
Jonathan Rainville 2024-07-03 14:55:07 -04:00 committed by GitHub
parent 459bbf7cc9
commit 35b64f0483
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 11 additions and 1 deletions

View File

@ -132,7 +132,6 @@ proc init*(self: Controller) =
let chat = self.chatService.getChatById(args.chatId) let chat = self.chatService.getChatById(args.chatId)
self.delegate.onMarkMessageAsUnread(chat) self.delegate.onMarkMessageAsUnread(chat)
self.events.on(chat_service.SIGNAL_CHAT_LEFT) do(e: Args): self.events.on(chat_service.SIGNAL_CHAT_LEFT) do(e: Args):
let args = chat_service.ChatArgs(e) let args = chat_service.ChatArgs(e)
self.delegate.onCommunityChannelDeletedOrChatLeft(args.chatId) self.delegate.onCommunityChannelDeletedOrChatLeft(args.chatId)

View File

@ -948,6 +948,7 @@ method onCategoryUnmuted*(self: Module, categoryId: string) =
method changeMutedOnChat*(self: Module, chatId: string, muted: bool) = method changeMutedOnChat*(self: Module, chatId: string, muted: bool) =
self.view.chatsModel().changeMutedOnItemById(chatId, muted) self.view.chatsModel().changeMutedOnItemById(chatId, muted)
self.updateParentBadgeNotifications()
proc changeCanPostValues*(self: Module, chatId: string, canPost, canView, canPostReactions, viewersCanPostReactions: bool) = proc changeCanPostValues*(self: Module, chatId: string, canPost, canView, canPostReactions, viewersCanPostReactions: bool) =
self.view.chatsModel().changeCanPostValues(chatId, canPost, canView, canPostReactions, viewersCanPostReactions) self.view.chatsModel().changeCanPostValues(chatId, canPost, canView, canPostReactions, viewersCanPostReactions)

View File

@ -575,6 +575,11 @@ QtObject:
error "error while mute chat ", msg error "error while mute chat ", msg
return 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)) self.events.emit(SIGNAL_CHAT_MUTED, ChatArgs(chatId: chatId))
except Exception as e: except Exception as e:
let errDesription = e.msg let errDesription = e.msg
@ -593,6 +598,11 @@ QtObject:
error "error while unmute chat ", msg error "error while unmute chat ", msg
return 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)) self.events.emit(SIGNAL_CHAT_UNMUTED, ChatArgs(chatId: chatId))
except Exception as e: except Exception as e:
let errDesription = e.msg let errDesription = e.msg