fix(chat): only add active chats (fixes chats reappearing after leaving)

Fixes #4903
This commit is contained in:
Jonathan Rainville 2022-03-07 13:08:26 -05:00
parent 13b81134de
commit a910a3e801
2 changed files with 8 additions and 2 deletions

View File

@ -110,9 +110,12 @@ QtObject:
# Handling chat updates # Handling chat updates
if (receivedData.chats.len > 0): if (receivedData.chats.len > 0):
var chats: seq[ChatDto] = @[]
for chatDto in receivedData.chats: for chatDto in receivedData.chats:
if (chatDto.active):
chats.add(chatDto)
self.updateOrAddChat(chatDto) self.updateOrAddChat(chatDto)
self.events.emit(SIGNAL_CHAT_UPDATE, ChatUpdateArgsNew(messages: receivedData.messages, chats: receivedData.chats)) self.events.emit(SIGNAL_CHAT_UPDATE, ChatUpdateArgsNew(messages: receivedData.messages, chats: chats))
proc init*(self: Service) = proc init*(self: Service) =
self.doConnect() self.doConnect()

View File

@ -138,6 +138,9 @@ QtObject:
error "error: received `chats` array for handling messages update is empty" error "error: received `chats` array for handling messages update is empty"
return return
if (not chats[0].active):
return
let chatId = chats[0].id let chatId = chats[0].id
let chatType = chats[0].chatType let chatType = chats[0].chatType
let unviewedMessagesCount = chats[0].unviewedMessagesCount let unviewedMessagesCount = chats[0].unviewedMessagesCount