From d45e78b3e054af4f7c4e539f312a3f1351ba9605 Mon Sep 17 00:00:00 2001 From: decanus <7621705+decanus@users.noreply.github.com> Date: Thu, 9 Jul 2020 18:15:14 +0200 Subject: [PATCH] fixed --- src/app/chat/views/channels_list.nim | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/app/chat/views/channels_list.nim b/src/app/chat/views/channels_list.nim index b25391f223..484dc10a9e 100644 --- a/src/app/chat/views/channels_list.nim +++ b/src/app/chat/views/channels_list.nim @@ -33,6 +33,11 @@ QtObject: result.status = status result.setup() + proc userNameOrAlias(self: ChannelsList, pubKey: string): string {.slot.} = + if self.status.chat.contacts.hasKey(pubKey): + return ens.userNameOrAlias(self.status.chat.contacts[pubKey]) + generateAlias(pubKey) + method rowCount(self: ChannelsList, index: QModelIndex = nil): int = self.chats.len proc renderBlock(self: ChannelsList, message: Message): string @@ -44,9 +49,14 @@ QtObject: return let chatItem = self.chats[index.row] + + var name = chatItem.name + if chatItem.chatType == ChatType.OneToOne: + name = self.userNameOrAlias(chatItem.id) + let chatItemRole = role.ChannelsRoles case chatItemRole: - of ChannelsRoles.Name: result = newQVariant(chatItem.name) + of ChannelsRoles.Name: result = newQVariant(name) of ChannelsRoles.Timestamp: result = newQVariant($chatItem.timestamp) of ChannelsRoles.LastMessage: result = newQVariant(self.renderBlock(chatItem.lastMessage)) of ChannelsRoles.UnreadMessages: result = newQVariant(chatItem.unviewedMessagesCount) @@ -126,14 +136,9 @@ QtObject: self.dataChanged(topLeft, bottomRight, @[ChannelsRoles.Name.int, ChannelsRoles.LastMessage.int, ChannelsRoles.Timestamp.int, ChannelsRoles.UnreadMessages.int, ChannelsRoles.Identicon.int, ChannelsRoles.ChatType.int, ChannelsRoles.Color.int, ChannelsRoles.HasMentions.int]) - proc mention(self: ChannelsList, pubKey: string): string = - if self.status.chat.contacts.hasKey(pubKey): - return ens.userNameOrAlias(self.status.chat.contacts[pubKey]) - generateAlias(pubKey) - proc renderInline(self: ChannelsList, elem: TextItem): string = case elem.textType: - of "mention": result = self.mention(elem.literal) + of "mention": result = self.userNameOrAlias(elem.literal) of "link": result = elem.destination else: result = elem.literal