From edf3e99f08dbeacddf3a16dc6b75a83036f5ebe9 Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Wed, 20 Jan 2021 13:05:02 -0500 Subject: [PATCH] fix: update muted channel state if the channel is the active one --- src/app/chat/view.nim | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/src/app/chat/view.nim b/src/app/chat/view.nim index 62609e74eb..44ac93014d 100644 --- a/src/app/chat/view.nim +++ b/src/app/chat/view.nim @@ -555,22 +555,6 @@ QtObject: read = isConnected notify = onlineStatusChanged - proc muteChannel*(self: ChatsView, channelIndex: int) {.slot.} = - if (self.chats.chats.len == 0): return - let selectedChannel = self.chats.getChannel(channelIndex) - if (selectedChannel == nil): return - selectedChannel.muted = true - self.status.chat.muteChat(selectedChannel) - self.chats.updateChat(selectedChannel) - - proc unmuteChannel*(self: ChatsView, channelIndex: int) {.slot.} = - if (self.chats.chats.len == 0): return - let selectedChannel = self.chats.getChannel(channelIndex) - if (selectedChannel == nil): return - selectedChannel.muted = false - self.status.chat.unmuteChat(selectedChannel) - self.chats.updateChat(selectedChannel) - proc muteCurrentChannel*(self: ChatsView) {.slot.} = self.activeChannel.mute() let channel = self.chats.getChannelById(self.activeChannel.id()) @@ -583,6 +567,29 @@ QtObject: channel.muted = false self.chats.updateChat(channel) + proc muteChannel*(self: ChatsView, channelIndex: int) {.slot.} = + if (self.chats.chats.len == 0): return + let selectedChannel = self.chats.getChannel(channelIndex) + if (selectedChannel == nil): return + if (selectedChannel.id == self.activeChannel.id): + self.muteCurrentChannel() + return + selectedChannel.muted = true + self.status.chat.muteChat(selectedChannel) + self.chats.updateChat(selectedChannel) + + proc unmuteChannel*(self: ChatsView, channelIndex: int) {.slot.} = + if (self.chats.chats.len == 0): return + let selectedChannel = self.chats.getChannel(channelIndex) + if (selectedChannel == nil): return + if (selectedChannel.id == self.activeChannel.id): + self.unmuteCurrentChannel() + return + selectedChannel.muted = false + self.status.chat.unmuteChat(selectedChannel) + self.chats.updateChat(selectedChannel) + + proc channelIsMuted*(self: ChatsView, channelIndex: int): bool {.slot.} = if (self.chats.chats.len == 0): return false let selectedChannel = self.chats.getChannel(channelIndex)