fix: show suggestion profile pics for contacts only

Fixes: #2365.

Previously, suggestions for mentions were showing profile pics even for users who were not contacts. Now, profile pics are only shown for those users who are contacts. The user’s identicon is shown otherwise.

fix: user thumbnail not shown when no profile pic
When a user was a contact, but didn’t have a profile pic, an image would not be loaded and a ‘reload’ image would be shown instead. With this PR, if the user is a contact and they do not have a profile pic, their identicon will be shown instead.
This commit is contained in:
Eric Mastro 2021-05-07 16:26:58 +10:00 committed by Iuri Matias
parent a0029ce270
commit 590192ad9e
2 changed files with 9 additions and 3 deletions

View File

@ -108,6 +108,7 @@ proc init*(self: ProfileController, account: Account) =
self.status.events.on("contactRemoved") do(e: Args):
let contacts = self.status.contacts.getContacts()
self.view.contacts.setContactList(contacts)
self.view.contactsChanged()
self.status.events.on("mailserver:changed") do(e: Args):
let mailserverArg = MailserverArgs(e)

View File

@ -72,13 +72,11 @@ StackLayout {
for (let i = 0; i < len; i++) {
const contactAddr = chatsModel.suggestionList.rowData(i, "address");
if(idMap[contactAddr]) continue;
const contactIndex = profileModel.contacts.list.getContactIndexByPubkey(chatsModel.suggestionList.rowData(i, "address"));
suggestionsObj.push({
alias: chatsModel.suggestionList.rowData(i, "alias"),
ensName: chatsModel.suggestionList.rowData(i, "ensName"),
address: contactAddr,
identicon: profileModel.contacts.list.rowData(contactIndex, "thumbnailImage"),
identicon: getProfileImage(contactAddr, false, false) || chatsModel.suggestionList.rowData(i, "identicon"),
localNickname: chatsModel.suggestionList.rowData(i, "localNickname")
})
@ -286,6 +284,13 @@ StackLayout {
}
}
Connections {
target: profileModel
onContactsChanged: {
populateSuggestions();
}
}
Rectangle {
id: inputArea
Layout.alignment: Qt.AlignHCenter | Qt.AlignBottom