fix channel missing a name when re-joining

This commit is contained in:
Jonathan Rainville 2022-01-28 17:07:40 -05:00 committed by Sale Djenic
parent 5ec9fe4ebd
commit e3a5c6bad3
2 changed files with 15 additions and 2 deletions

View File

@ -155,9 +155,10 @@ QtObject:
proc getChatsOfChatTypes*(self: Service, types: seq[chat_dto.ChatType]): seq[ChatDto] =
return self.getAllChats().filterIt(it.chatType in types)
proc getChatById*(self: Service, chatId: string): ChatDto =
proc getChatById*(self: Service, chatId: string, showWarning: bool = true): ChatDto =
if(not self.chats.contains(chatId)):
error "trying to get chat data for an unexisting chat id", chatId
if (showWarning):
warn "trying to get chat data for an unexisting chat id", chatId
return
return self.chats[chatId]

View File

@ -312,6 +312,18 @@ QtObject:
var community = self.allCommunities[communityId]
self.joinedCommunities[communityId] = community
for k, chat in community.chats:
let fullChatId = communityId & chat.id
let currentChat = self.chatService.getChatById(fullChatId, showWarning = false)
echo currentChat
if (currentChat.id != ""):
# The chat service already knows that about that chat
continue
var chatDto = mapChatToChatDto(chat, communityId)
chatDto.id = fullChatId
# TODO find a way to populate missing infos like the color
self.chatService.updateOrAddChat(chatDto)
self.events.emit(SIGNAL_COMMUNITY_JOINED, CommunityArgs(community: community))
except Exception as e:
error "Error joining the community", msg = e.msg