From d49be78417fbca3770e1c25db3fcaa98d80505c5 Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Thu, 19 Nov 2020 15:07:27 -0500 Subject: [PATCH] feat: show nickname if there is one in the mentions --- src/app/chat/views/suggestions_list.nim | 6 +++++- ui/app/AppLayouts/Chat/ChatColumn.qml | 18 ++++++++++-------- ui/shared/status/StatusChatInput.qml | 2 +- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/app/chat/views/suggestions_list.nim b/src/app/chat/views/suggestions_list.nim index 6d623525f2..ae2206f81d 100644 --- a/src/app/chat/views/suggestions_list.nim +++ b/src/app/chat/views/suggestions_list.nim @@ -8,6 +8,7 @@ type Address = UserRole + 3, EnsName = UserRole + 4, EnsVerified = UserRole + 5 + LocalNickname = UserRole + 6 QtObject: type SuggestionsList* = ref object of QAbstractListModel @@ -25,7 +26,7 @@ QtObject: result.setup proc rowData(self: SuggestionsList, index: int, column: string): string {.slot.} = - if (index >= self.suggestions.len - 1): + if (index >= self.suggestions.len): return let suggestion = self.suggestions[index] case column: @@ -33,6 +34,7 @@ QtObject: of "ensName": result = suggestion.ensName of "address": result = suggestion.address of "identicon": result = suggestion.identicon + of "localNickname": result = suggestion.localNickname method rowCount(self: SuggestionsList, index: QModelIndex = nil): int = return self.suggestions.len @@ -50,12 +52,14 @@ QtObject: of SuggestionRoles.Address: result = newQVariant(suggestion.address) of SuggestionRoles.EnsName: result = newQVariant(suggestion.ensName) of SuggestionRoles.EnsVerified: result = newQVariant(suggestion.ensVerified) + of SuggestionRoles.LocalNickname: result = newQVariant(suggestion.localNickname) method roleNames(self: SuggestionsList): Table[int, string] = { SuggestionRoles.Alias.int:"alias", SuggestionRoles.Identicon.int:"identicon", SuggestionRoles.Address.int:"address", SuggestionRoles.EnsName.int:"ensName", + SuggestionRoles.LocalNickname.int:"localNickname", SuggestionRoles.EnsVerified.int:"ensVerified" }.toTable proc addSuggestionToList*(self: SuggestionsList, profile: Profile) = diff --git a/ui/app/AppLayouts/Chat/ChatColumn.qml b/ui/app/AppLayouts/Chat/ChatColumn.qml index 1913ff3b1d..c7a638c3c9 100644 --- a/ui/app/AppLayouts/Chat/ChatColumn.qml +++ b/ui/app/AppLayouts/Chat/ChatColumn.qml @@ -164,14 +164,16 @@ StackLayout { onActiveChannelChanged: { chatInput.textInput.forceActiveFocus(Qt.MouseFocusReason) suggestions.clear() - for (let i = 0; i < chatsModel.suggestionList.rowCount(); i++) { - suggestions.append({ - alias: chatsModel.suggestionList.rowData(i, "alias"), - ensName: chatsModel.suggestionList.rowData(i, "ensName"), - address: chatsModel.suggestionList.rowData(i, "address"), - identicon: chatsModel.suggestionList.rowData(i, "identicon"), - ensVerified: chatsModel.suggestionList.rowData(i, "ensVerified") - }); + const len = chatsModel.suggestionList.rowCount() + for (let i = 0; i < len; i++) { + suggestions.append({ + alias: chatsModel.suggestionList.rowData(i, "alias"), + ensName: chatsModel.suggestionList.rowData(i, "ensName"), + address: chatsModel.suggestionList.rowData(i, "address"), + identicon: chatsModel.suggestionList.rowData(i, "identicon"), + ensVerified: chatsModel.suggestionList.rowData(i, "ensVerified"), + localNickname: chatsModel.suggestionList.rowData(i, "localNickname") + }); } } } diff --git a/ui/shared/status/StatusChatInput.qml b/ui/shared/status/StatusChatInput.qml index fb33cf7d68..b8df15f159 100644 --- a/ui/shared/status/StatusChatInput.qml +++ b/ui/shared/status/StatusChatInput.qml @@ -368,7 +368,7 @@ Rectangle { width: messageInput.width filter: messageInputField.text cursorPosition: messageInputField.cursorPosition - property: "ensName, alias" + property: "ensName, localNickname, alias" onItemSelected: function (item, lastAtPosition, lastCursorPosition) { let hasEmoji = Emoji.hasEmoji(messageInputField.text) let currentText = hasEmoji ?