fix(@desktop/chat): prevent double addition of private chat

This commit is contained in:
Anthony Laibe 2021-07-22 14:03:53 +02:00 committed by Iuri Matias
parent e88665f27a
commit aec0130107
1 changed files with 11 additions and 3 deletions

View File

@ -103,9 +103,17 @@ QtObject:
self.endResetModel()
proc addChatItemToList*(self: ChannelsList, channel: Chat): int =
self.beginInsertRows(newQModelIndex(), 0, 0)
self.chats.insert(channel, 0)
self.endInsertRows()
var found = false
for chat in self.chats:
if chat.id == channel.id:
found = true
break
if not found:
self.beginInsertRows(newQModelIndex(), 0, 0)
self.chats.insert(channel, 0)
self.endInsertRows()
result = 0
proc removeChatItemFromList*(self: ChannelsList, channel: string): int =