fix: update muted channel state if the channel is the active one

This commit is contained in:
Jonathan Rainville 2021-01-20 13:05:02 -05:00 committed by Iuri Matias
parent f5bcaa5ac5
commit edf3e99f08
1 changed files with 23 additions and 16 deletions

View File

@ -555,22 +555,6 @@ QtObject:
read = isConnected read = isConnected
notify = onlineStatusChanged 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.} = proc muteCurrentChannel*(self: ChatsView) {.slot.} =
self.activeChannel.mute() self.activeChannel.mute()
let channel = self.chats.getChannelById(self.activeChannel.id()) let channel = self.chats.getChannelById(self.activeChannel.id())
@ -583,6 +567,29 @@ QtObject:
channel.muted = false channel.muted = false
self.chats.updateChat(channel) 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.} = proc channelIsMuted*(self: ChatsView, channelIndex: int): bool {.slot.} =
if (self.chats.chats.len == 0): return false if (self.chats.chats.len == 0): return false
let selectedChannel = self.chats.getChannel(channelIndex) let selectedChannel = self.chats.getChannel(channelIndex)