From 8fb944023550b90eea0f7f5973fb35e286f21755 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Cie=C5=9Blak?= Date: Tue, 15 Oct 2024 11:58:09 +0200 Subject: [PATCH] ContactsStore: getProfileContext simplified --- ui/app/AppLayouts/Chat/panels/UserListPanel.qml | 2 +- .../AppLayouts/Communities/panels/MembersTabPanel.qml | 2 +- ui/app/AppLayouts/Profile/stores/ContactsStore.qml | 10 +++++----- ui/app/AppLayouts/Profile/views/ContactsView.qml | 2 +- ui/imports/shared/views/chat/MessageView.qml | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ui/app/AppLayouts/Chat/panels/UserListPanel.qml b/ui/app/AppLayouts/Chat/panels/UserListPanel.qml index 1c4a52a762..3d54265065 100644 --- a/ui/app/AppLayouts/Chat/panels/UserListPanel.qml +++ b/ui/app/AppLayouts/Chat/panels/UserListPanel.qml @@ -118,7 +118,7 @@ Item { ringSettings.ringSpecModel: model.colorHash onClicked: { if (mouse.button === Qt.RightButton) { - const { profileType, trustStatus, contactType, ensVerified, onlineStatus, hasLocalNickname } = root.store.contactsStore.getProfileContext(model.pubKey, userProfile.pubKey) + const { profileType, trustStatus, contactType, ensVerified, onlineStatus, hasLocalNickname } = root.store.contactsStore.getProfileContext(model.pubKey) const chatType = chatContentModule.chatDetails.type const isAdmin = chatContentModule.amIChatAdmin() diff --git a/ui/app/AppLayouts/Communities/panels/MembersTabPanel.qml b/ui/app/AppLayouts/Communities/panels/MembersTabPanel.qml index 5838160c63..4d324697c6 100644 --- a/ui/app/AppLayouts/Communities/panels/MembersTabPanel.qml +++ b/ui/app/AppLayouts/Communities/panels/MembersTabPanel.qml @@ -311,7 +311,7 @@ Item { onClicked: { if(mouse.button === Qt.RightButton) { - const { profileType, trustStatus, contactType, ensVerified, onlineStatus, hasLocalNickname } = root.rootStore.contactsStore.getProfileContext(model.pubKey, Global.userProfile.pubKey) + const { profileType, trustStatus, contactType, ensVerified, onlineStatus, hasLocalNickname } = root.rootStore.contactsStore.getProfileContext(model.pubKey) Global.openMenu(memberContextMenuComponent, this, { profileType, trustStatus, contactType, ensVerified, onlineStatus, hasLocalNickname, diff --git a/ui/app/AppLayouts/Profile/stores/ContactsStore.qml b/ui/app/AppLayouts/Profile/stores/ContactsStore.qml index 4a35de4629..bd9df404ce 100644 --- a/ui/app/AppLayouts/Profile/stores/ContactsStore.qml +++ b/ui/app/AppLayouts/Profile/stores/ContactsStore.qml @@ -178,11 +178,11 @@ QtObject { function getLinkToProfile(publicKey) { return root.contactsModule.shareUserUrlWithData(publicKey) } - function getProfileContext(publicKey, myPublicKey, isBridgedAccount = false) { + function getProfileContext(publicKey, isBridgedAccount = false) { const contactDetails = Utils.getContactDetailsAsJson(publicKey, true, true) if (!contactDetails) return { - profileType: getProfileType(publicKey, myPublicKey, isBridgedAccount, false), + profileType: getProfileType(publicKey, isBridgedAccount, false), trustStatus: Constants.trustStatus.unknown, contactType: getContactType(Constants.ContactRequestState.None, false), ensVerified: false, @@ -191,7 +191,7 @@ QtObject { } const isBlocked = contactDetails.isBlocked - const profileType = getProfileType(publicKey, myPublicKey, isBridgedAccount, isBlocked) + const profileType = getProfileType(publicKey, isBridgedAccount, isBlocked) const contactType = getContactType(contactDetails.contactRequestState, contactDetails.isContact) const trustStatus = contactDetails.trustStatus const ensVerified = contactDetails.ensVerified @@ -201,8 +201,8 @@ QtObject { return { profileType, trustStatus, contactType, ensVerified, onlineStatus, hasLocalNickname } } - function getProfileType(publicKey, myPublicKey, isBridgedAccount, isBlocked) { - if (publicKey === myPublicKey) return Constants.profileType.self + function getProfileType(publicKey, isBridgedAccount, isBlocked) { + if (publicKey === root.myPublicKey) return Constants.profileType.self if (isBridgedAccount) return Constants.profileType.bridged if (isBlocked) return Constants.profileType.blocked return Constants.profileType.regular diff --git a/ui/app/AppLayouts/Profile/views/ContactsView.qml b/ui/app/AppLayouts/Profile/views/ContactsView.qml index e79b7537bd..4db7169ff0 100644 --- a/ui/app/AppLayouts/Profile/views/ContactsView.qml +++ b/ui/app/AppLayouts/Profile/views/ContactsView.qml @@ -34,7 +34,7 @@ SettingsContentBase { } function openContextMenu(publicKey, name, icon) { - const { profileType, trustStatus, contactType, ensVerified, onlineStatus, hasLocalNickname } = root.contactsStore.getProfileContext(publicKey, root.contactsStore.myPublicKey) + const { profileType, trustStatus, contactType, ensVerified, onlineStatus, hasLocalNickname } = root.contactsStore.getProfileContext(publicKey) Global.openMenu(contactContextMenuComponent, this, { profileType, trustStatus, contactType, ensVerified, onlineStatus, hasLocalNickname, diff --git a/ui/imports/shared/views/chat/MessageView.qml b/ui/imports/shared/views/chat/MessageView.qml index 731a78b0bf..91cf22cebc 100644 --- a/ui/imports/shared/views/chat/MessageView.qml +++ b/ui/imports/shared/views/chat/MessageView.qml @@ -162,7 +162,7 @@ Loader { } const publicKey = isReply ? quotedMessageFrom : root.senderId const isBridgedAccount = isReply ? (quotedMessageContentType === Constants.messageContentType.bridgeMessageType) : root.isBridgeMessage - const { profileType, trustStatus, contactType, ensVerified, onlineStatus, hasLocalNickname } = root.contactsStore.getProfileContext(publicKey, root.rootStore.contactsStore.myPublicKey, isBridgedAccount) + const { profileType, trustStatus, contactType, ensVerified, onlineStatus, hasLocalNickname } = root.contactsStore.getProfileContext(publicKey, isBridgedAccount) const chatType = chatContentModule.chatDetails.type // set false for now, because the remove from group option is still available after member is removed const isAdmin = false // chatContentModule.amIChatAdmin()