mirror of
https://github.com/status-im/status-desktop.git
synced 2025-01-23 04:50:28 +00:00
fix: avoid moving the channel to top when switching a channel or marking it as read
This commit is contained in:
parent
c4eb92b5e8
commit
9151cbe849
@ -14,6 +14,10 @@ proc handleChatEvents(self: ChatController) =
|
||||
self.view.updateChats(evArgs.chats)
|
||||
self.view.pushMessages(evArgs.messages)
|
||||
|
||||
self.status.events.on("channelUpdate") do(e: Args):
|
||||
var evArgs = ChatUpdateArgs(e)
|
||||
self.view.updateChats(evArgs.chats, false)
|
||||
|
||||
self.status.events.on("chatHistoryCleared") do(e: Args):
|
||||
var args = ChannelArgs(e)
|
||||
self.view.clearMessages(args.chat.id)
|
||||
|
@ -287,13 +287,14 @@ QtObject:
|
||||
self.unreadMessageCnt = unreadTotal
|
||||
self.unreadMessagesCntChanged()
|
||||
|
||||
proc updateChats*(self: ChatsView, chats: seq[Chat]) =
|
||||
proc updateChats*(self: ChatsView, chats: seq[Chat], triggerChange:bool = true) =
|
||||
for chat in chats:
|
||||
self.upsertChannel(chat.id)
|
||||
self.chats.updateChat(chat)
|
||||
self.chats.updateChat(chat, triggerChange)
|
||||
if(self.activeChannel.id == chat.id):
|
||||
self.activeChannel.setChatItem(chat)
|
||||
self.currentSuggestions.setNewData(self.status.contacts.getContacts())
|
||||
if triggerChange:
|
||||
self.activeChannelChanged()
|
||||
self.calculateUnreadMessages()
|
||||
|
||||
|
@ -113,12 +113,14 @@ QtObject:
|
||||
if chat.name == name:
|
||||
return chat.color
|
||||
|
||||
proc updateChat*(self: ChannelsList, channel: Chat) =
|
||||
proc updateChat*(self: ChannelsList, channel: Chat, moveToTop: bool = true) =
|
||||
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)
|
||||
|
@ -257,7 +257,7 @@ proc markAllChannelMessagesRead*(self: ChatModel, chatId: string): JsonNode =
|
||||
result = parseJson(response)
|
||||
if self.channels.hasKey(chatId):
|
||||
self.channels[chatId].unviewedMessagesCount = 0
|
||||
self.events.emit("chatUpdate", ChatUpdateArgs(messages: @[], chats: @[self.channels[chatId]], contacts: @[]))
|
||||
self.events.emit("channelUpdate", ChatUpdateArgs(messages: @[], chats: @[self.channels[chatId]], contacts: @[]))
|
||||
|
||||
|
||||
proc confirmJoiningGroup*(self: ChatModel, chatId: string) =
|
||||
|
Loading…
x
Reference in New Issue
Block a user