diff --git a/ui/app/AppLayouts/Chat/ChatColumn/Message.qml b/ui/app/AppLayouts/Chat/ChatColumn/Message.qml index 23e3944f9d..339edc95bb 100644 --- a/ui/app/AppLayouts/Chat/ChatColumn/Message.qml +++ b/ui/app/AppLayouts/Chat/ChatColumn/Message.qml @@ -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 diff --git a/ui/app/AppLayouts/Chat/ChatLayout.qml b/ui/app/AppLayouts/Chat/ChatLayout.qml index df451bd449..3fcc881306 100644 --- a/ui/app/AppLayouts/Chat/ChatLayout.qml +++ b/ui/app/AppLayouts/Chat/ChatLayout.qml @@ -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: { diff --git a/ui/app/AppLayouts/Chat/CommunityComponents/CommunityMembersPopup.qml b/ui/app/AppLayouts/Chat/CommunityComponents/CommunityMembersPopup.qml index e579769fa2..755d665dd9 100644 --- a/ui/app/AppLayouts/Chat/CommunityComponents/CommunityMembersPopup.qml +++ b/ui/app/AppLayouts/Chat/CommunityComponents/CommunityMembersPopup.qml @@ -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 diff --git a/ui/app/AppLayouts/Chat/components/GroupInfoPopup.qml b/ui/app/AppLayouts/Chat/components/GroupInfoPopup.qml index 1ebd7f1a57..c4dc020025 100644 --- a/ui/app/AppLayouts/Chat/components/GroupInfoPopup.qml +++ b/ui/app/AppLayouts/Chat/components/GroupInfoPopup.qml @@ -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 diff --git a/ui/nim-status-client.pro b/ui/nim-status-client.pro index b11a490caf..cd796aea65 100644 --- a/ui/nim-status-client.pro +++ b/ui/nim-status-client.pro @@ -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 \