feat: show nickname if there is one in the mentions

This commit is contained in:
Jonathan Rainville 2020-11-19 15:07:27 -05:00 committed by Iuri Matias
parent 6f3749d787
commit d49be78417
3 changed files with 16 additions and 10 deletions

View File

@ -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) =

View File

@ -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")
});
}
}
}

View File

@ -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 ?