fix: populate suggestion box with all users from the message list

Fixes: #1328
This commit is contained in:
Richard Ramos 2021-02-03 16:13:05 -04:00 committed by Iuri Matias
parent 7da6bd9834
commit d0de5c074f
3 changed files with 44 additions and 14 deletions

View File

@ -212,8 +212,10 @@ QtObject:
let message = self.messages[index]
case data:
of "userName": result = (message.userName)
of "publicKey": result = (message.fromAuthor)
of "alias": result = (message.alias)
of "localName": result = (message.localName)
of "ensName": result = (message.ensName)
of "message": result = (message.text)
of "identicon": result = (message.identicon)
of "timestamp": result = $(message.timestamp)

View File

@ -41,6 +41,41 @@ StackLayout {
currentIndex: chatsModel.activeChannelIndex > -1 && chatGroupsListViewCount > 0 ? 0 : 1
function populateSuggestions(){
chatInput.textInput.forceActiveFocus(Qt.MouseFocusReason)
chatInput.suggestionsList.clear()
const len = chatsModel.suggestionList.rowCount()
var idMap = {}
for (let i = 0; i < len; i++) {
const contactAddr = chatsModel.suggestionList.rowData(i, "address");
if(idMap[contactAddr]) continue;
chatInput.suggestionsList.append({
alias: chatsModel.suggestionList.rowData(i, "alias"),
ensName: chatsModel.suggestionList.rowData(i, "ensName"),
address: contactAddr,
identicon: chatsModel.suggestionList.rowData(i, "identicon"),
localNickname: chatsModel.suggestionList.rowData(i, "localNickname")
});
idMap[contactAddr] = true;
}
const len2 = chatsModel.messageList.rowCount();
for (let i = 0; i < len2; i++) {
const contactAddr = chatsModel.messageList.getMessageData(i, "publicKey");
if(idMap[contactAddr]) continue;
chatInput.suggestionsList.append({
alias: chatsModel.messageList.getMessageData(i, "alias"),
ensName: chatsModel.messageList.getMessageData(i, "ensName"),
address: contactAddr,
identicon: chatsModel.messageList.getMessageData(i, "identicon"),
localNickname: chatsModel.messageList.getMessageData(i, "localName")
});
idMap[contactAddr] = true;
}
}
function showReplyArea() {
isReply = true;
isImage = false;
@ -165,23 +200,15 @@ StackLayout {
MessageContextMenu {
id: messageContextMenu
}
Connections {
target: chatsModel
onActiveChannelChanged: {
chatInput.textInput.forceActiveFocus(Qt.MouseFocusReason)
chatInput.suggestionsList.clear()
const len = chatsModel.suggestionList.rowCount()
for (let i = 0; i < len; i++) {
chatInput.suggestionsList.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")
});
}
chatInput.suggestions.hide();
populateSuggestions();
}
onMessagePushed: {
populateSuggestions();
}
}

View File

@ -42,6 +42,7 @@ Rectangle {
property alias messageSound: sendMessageSound
property alias suggestionsList: suggestions
property alias suggestions: suggestionsBox
height: {
if (extendedArea.visible) {