refactor: use getNickname function for nicknames fetches

This commit is contained in:
Jonathan Rainville 2020-12-21 12:09:00 -05:00 committed by Iuri Matias
parent a22c5942ff
commit 29a9ca4ef5
5 changed files with 16 additions and 33 deletions

View File

@ -90,15 +90,7 @@ Item {
SelectedMessage.set(messageId, fromAuthor);
}
// Get contact nickname
const contactList = profileModel.contacts.list
const contactCount = contactList.rowCount()
let nickname = ""
for (let i = 0; i < contactCount; i++) {
if (contactList.rowData(i, 'pubKey') === fromAuthor) {
nickname = contactList.rowData(i, 'localNickname')
break;
}
}
let nickname = chatView.getUserNickname(fromAuthor)
messageContextMenu.isProfile = !!isProfileClick
messageContextMenu.isSticker = isSticker
messageContextMenu.emojiOnly = emojiOnly

View File

@ -47,6 +47,18 @@ SplitView {
return contacts
}
function getUserNickname(pubKey) {
// Get contact nickname
const contactList = profileModel.contacts.list
const contactCount = contactList.rowCount()
for (let i = 0; i < contactCount; i++) {
if (contactList.rowData(i, 'pubKey') === pubKey) {
return contactList.rowData(i, 'localNickname')
}
}
return ""
}
Connections {
target: applicationWindow
onSettingsLoaded: {

View File

@ -80,18 +80,7 @@ ModalPopup {
width: parent.width
height: identicon.height
property string nickname: {
// Get contact nickname
const contactList = profileModel.contacts.list
const contactCount = contactList.rowCount()
let nickname = ""
for (let i = 0; i < contactCount; i++) {
if (contactList.rowData(i, 'pubKey') === model.pubKey) {
return contactList.rowData(i, 'localNickname')
}
}
return ""
}
property string nickname: chatView.getUserNickname(model.pubKey)
StatusImageIdenticon {
id: identicon

View File

@ -210,18 +210,7 @@ ModalPopup {
width: parent.width
height: identicon.height
property string nickname: {
// Get contact nickname
const contactList = profileModel.contacts.list
const contactCount = contactList.rowCount()
let nickname = ""
for (let i = 0; i < contactCount; i++) {
if (contactList.rowData(i, 'pubKey') === model.pubKey) {
return contactList.rowData(i, 'localNickname')
}
}
return ""
}
property string nickname: chatView.getUserNickname(model.pubKey)
StatusImageIdenticon {
id: identicon

View File

@ -172,6 +172,7 @@ DISTFILES += \
app/AppLayouts/Chat/CommunityComponents/CommunitiesPopup.qml \
app/AppLayouts/Chat/CommunityComponents/CommunityButton.qml \
app/AppLayouts/Chat/CommunityComponents/CommunityDetailPopup.qml \
app/AppLayouts/Chat/CommunityComponents/CommunityMembersPopup.qml \
app/AppLayouts/Chat/CommunityComponents/CommunityList.qml \
app/AppLayouts/Chat/CommunityComponents/CommunityWelcomeBanner.qml \
app/AppLayouts/Chat/CommunityComponents/CreateChannelPopup.qml \