fix: fix channels reordering and messing up the profile image
This commit is contained in:
parent
4aeeee6d9c
commit
0ff5fa32f0
|
@ -31,7 +31,7 @@ proc handleChatEvents(self: ChatController) =
|
|||
|
||||
self.status.events.on("channelUpdate") do(e: Args):
|
||||
var evArgs = ChatUpdateArgs(e)
|
||||
self.view.updateChats(evArgs.chats, false)
|
||||
self.view.updateChats(evArgs.chats)
|
||||
|
||||
self.status.events.on("messageDeleted") do(e: Args):
|
||||
var evArgs = MessageArgs(e)
|
||||
|
|
|
@ -352,7 +352,7 @@ QtObject:
|
|||
channel.name = contact.username
|
||||
else:
|
||||
channel.name = contact.localNickname
|
||||
self.chats.updateChat(channel, false)
|
||||
self.chats.updateChat(channel)
|
||||
if (self.activeChannel.id == channel.id):
|
||||
self.activeChannel.setChatItem(channel)
|
||||
self.activeChannelChanged()
|
||||
|
@ -487,12 +487,12 @@ QtObject:
|
|||
self.unreadMessageCnt = unreadTotal
|
||||
self.unreadMessagesCntChanged()
|
||||
|
||||
proc updateChats*(self: ChatsView, chats: seq[Chat], triggerChange:bool = true) =
|
||||
proc updateChats*(self: ChatsView, chats: seq[Chat]) =
|
||||
for chat in chats:
|
||||
if (chat.communityId != ""):
|
||||
return
|
||||
self.upsertChannel(chat.id)
|
||||
self.chats.updateChat(chat, triggerChange)
|
||||
self.chats.updateChat(chat)
|
||||
if(self.activeChannel.id == chat.id):
|
||||
self.activeChannel.setChatItem(chat)
|
||||
self.currentSuggestions.setNewData(self.status.contacts.getContacts())
|
||||
|
@ -540,7 +540,7 @@ QtObject:
|
|||
if (selectedChannel == nil): return
|
||||
selectedChannel.muted = true
|
||||
self.status.chat.muteChat(selectedChannel)
|
||||
self.chats.updateChat(selectedChannel, false)
|
||||
self.chats.updateChat(selectedChannel)
|
||||
|
||||
proc unmuteChannel*(self: ChatsView, channelIndex: int) {.slot.} =
|
||||
if (self.chats.chats.len == 0): return
|
||||
|
@ -548,7 +548,7 @@ QtObject:
|
|||
if (selectedChannel == nil): return
|
||||
selectedChannel.muted = false
|
||||
self.status.chat.unmuteChat(selectedChannel)
|
||||
self.chats.updateChat(selectedChannel, false)
|
||||
self.chats.updateChat(selectedChannel)
|
||||
|
||||
proc channelIsMuted*(self: ChatsView, channelIndex: int): bool {.slot.} =
|
||||
if (self.chats.chats.len == 0): return false
|
||||
|
|
|
@ -143,20 +143,13 @@ QtObject:
|
|||
if (channel == nil): return
|
||||
return channel.color
|
||||
|
||||
proc updateChat*(self: ChannelsList, channel: Chat, moveToTop: bool = true) =
|
||||
proc updateChat*(self: ChannelsList, channel: Chat) =
|
||||
let idx = self.upsertChannel(channel)
|
||||
if idx == -1: return
|
||||
|
||||
let topLeft = self.createIndex(0, 0, nil)
|
||||
let bottomRight = self.createIndex(self.chats.len, 0, nil)
|
||||
|
||||
if moveToTop:
|
||||
if idx != 0: # Move last updated chat to the top of the list
|
||||
self.chats.delete(idx)
|
||||
self.chats.insert(channel, 0)
|
||||
else:
|
||||
self.chats[0] = channel
|
||||
|
||||
self.dataChanged(topLeft, bottomRight, @[ChannelsRoles.Name.int, ChannelsRoles.Description.int, ChannelsRoles.ContentType.int, ChannelsRoles.LastMessage.int, ChannelsRoles.Timestamp.int, ChannelsRoles.UnreadMessages.int, ChannelsRoles.Identicon.int, ChannelsRoles.ChatType.int, ChannelsRoles.Color.int, ChannelsRoles.HasMentions.int, ChannelsRoles.Muted.int])
|
||||
|
||||
proc clearUnreadMessagesCount*(self: ChannelsList, channel: var Chat) =
|
||||
|
|
Loading…
Reference in New Issue