From 02993196e9da82fdbee56f07c76eb9e530e6bc41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Cie=C5=9Blak?= Date: Tue, 15 Oct 2024 14:26:45 +0200 Subject: [PATCH] References to Global.userProfile removed from multiple components --- storybook/pages/MembersTabPanelPage.qml | 20 +++++++++---------- storybook/pages/ProfileDialogViewPage.qml | 8 -------- .../Communities/panels/MembersTabPanel.qml | 3 +-- ui/app/AppLayouts/Profile/ProfileLayout.qml | 1 + .../Profile/stores/ContactsStore.qml | 2 +- .../Profile/stores/EnsUsernamesStore.qml | 8 ++++---- ui/app/mainui/AppMain.qml | 3 +++ ui/app/mainui/Popups.qml | 4 ++++ ...utgoingContactVerificationRequestPopup.qml | 16 +++++++++------ .../shared/popups/keycard/KeycardPopup.qml | 2 ++ .../popups/keycard/KeycardPopupContent.qml | 3 +++ .../keycard/states/KeycardConfirmation.qml | 8 ++++---- 12 files changed, 42 insertions(+), 36 deletions(-) diff --git a/storybook/pages/MembersTabPanelPage.qml b/storybook/pages/MembersTabPanelPage.qml index fda5bfd2bb..0a88079f92 100644 --- a/storybook/pages/MembersTabPanelPage.qml +++ b/storybook/pages/MembersTabPanelPage.qml @@ -5,6 +5,8 @@ import QtQuick.Layouts 1.15 import Qt.labs.settings 1.0 import AppLayouts.Communities.panels 1.0 +import AppLayouts.Chat.stores 1.0 as ChatStores +import AppLayouts.Profile.stores 1.0 as ProfileStores import utils 1.0 @@ -15,6 +17,7 @@ import Storybook 1.0 import StatusQ 0.1 import StatusQ.Core.Utils 0.1 as SQUtils + SplitView { id: root @@ -48,17 +51,6 @@ SplitView { } } - // Global.userProfile mock - QtObject { - readonly property string pubKey: "0x043a7ed0e8d1012cf04" // Mike from UsersModel - Component.onCompleted: { - Global.userProfile = this - } - Component.onDestruction: { - Global.userProfile = {} - } - } - MembersTabPanel { id: membersTabPanelPage SplitView.fillWidth: true @@ -67,6 +59,12 @@ SplitView { model: usersModelWithMembershipState panelType: viewStateSelector.currentValue + rootStore: ChatStores.RootStore { + contactsStore: ProfileStores.ContactsStore { + readonly property string myPublicKey: "0x000" + } + } + onKickUserClicked: { logs.logEvent("MembersTabPanel::onKickUserClicked", ["id", "name"], arguments) } diff --git a/storybook/pages/ProfileDialogViewPage.qml b/storybook/pages/ProfileDialogViewPage.qml index 2ed66ef5cf..7638b6b3cb 100644 --- a/storybook/pages/ProfileDialogViewPage.qml +++ b/storybook/pages/ProfileDialogViewPage.qml @@ -100,14 +100,6 @@ SplitView { } } - Component.onCompleted: { - Global.userProfile = { - name: "Anna", - pubKey: "Oxdeadbeef", - icon: ModelsData.collectibles.cryptoPunks - } - } - ListModel { id: linksModel ListElement { diff --git a/ui/app/AppLayouts/Communities/panels/MembersTabPanel.qml b/ui/app/AppLayouts/Communities/panels/MembersTabPanel.qml index 4d324697c6..9745dcaa3a 100644 --- a/ui/app/AppLayouts/Communities/panels/MembersTabPanel.qml +++ b/ui/app/AppLayouts/Communities/panels/MembersTabPanel.qml @@ -150,7 +150,7 @@ Item { // The admin that initited the pending state can change the state. Actions are not visible for other admins readonly property bool ctaAllowed: !isRejectedPending && !isAcceptedPending && !isBanPending && !isUnbanPending && !isKickPending - readonly property bool itsMe: model.pubKey.toLowerCase() === Global.userProfile.pubKey.toLowerCase() + readonly property bool itsMe: model.pubKey.toLowerCase() === rootStore.contactsStore.myPublicKey.toLowerCase() readonly property bool isHovered: memberItem.hovered readonly property bool canBeBanned: { if (memberItem.itsMe) { @@ -315,7 +315,6 @@ Item { Global.openMenu(memberContextMenuComponent, this, { profileType, trustStatus, contactType, ensVerified, onlineStatus, hasLocalNickname, - myPublicKey: Global.userProfile.pubKey, publicKey: model.pubKey, displayName: memberItem.title || model.displayName, userIcon: icon.name, diff --git a/ui/app/AppLayouts/Profile/ProfileLayout.qml b/ui/app/AppLayouts/Profile/ProfileLayout.qml index b0eff2c57f..fc701020c6 100644 --- a/ui/app/AppLayouts/Profile/ProfileLayout.qml +++ b/ui/app/AppLayouts/Profile/ProfileLayout.qml @@ -496,6 +496,7 @@ StatusSectionLayout { id: keycardPopup active: false sourceComponent: KeycardPopup { + myKeyUid: store.profileStore.keyUid sharedKeycardModule: root.store.keycardStore.keycardModule.keycardSharedModule emojiPopup: root.emojiPopup } diff --git a/ui/app/AppLayouts/Profile/stores/ContactsStore.qml b/ui/app/AppLayouts/Profile/stores/ContactsStore.qml index bd9df404ce..33abed52dd 100644 --- a/ui/app/AppLayouts/Profile/stores/ContactsStore.qml +++ b/ui/app/AppLayouts/Profile/stores/ContactsStore.qml @@ -11,7 +11,7 @@ QtObject { property var globalUtilsInst: globalUtils property var mainModuleInst: Global.appIsReady? mainModule : null - property string myPublicKey: !!Global.userProfile? Global.userProfile.pubKey : "" + property string myPublicKey: userProfile.pubKey // contactsModel holds all available contacts property var contactsModel: contactsModule.contactsModel diff --git a/ui/app/AppLayouts/Profile/stores/EnsUsernamesStore.qml b/ui/app/AppLayouts/Profile/stores/EnsUsernamesStore.qml index 8620d3eb53..85946debcc 100644 --- a/ui/app/AppLayouts/Profile/stores/EnsUsernamesStore.qml +++ b/ui/app/AppLayouts/Profile/stores/EnsUsernamesStore.qml @@ -17,12 +17,12 @@ QtObject { } } - property string pubkey: !!Global.userProfile? Global.userProfile.pubKey : "" - property string icon: !!Global.userProfile? Global.userProfile.icon : "" - property string preferredUsername: !!Global.userProfile? Global.userProfile.preferredName : "" + property string pubkey: userProfile.pubKey + property string icon: userProfile.icon + property string preferredUsername: userProfile.preferredName readonly property string chainId: mainModule.appNetworkId - property string username: !!Global.userProfile? Global.userProfile.username : "" + property string username: userProfile.username function setPrefferedEnsUsername(ensName) { if(!root.ensUsernamesModule) diff --git a/ui/app/mainui/AppMain.qml b/ui/app/mainui/AppMain.qml index 5a62405e14..24cf4f25db 100644 --- a/ui/app/mainui/AppMain.qml +++ b/ui/app/mainui/AppMain.qml @@ -421,6 +421,7 @@ Item { rootStore: appMain.rootStore communityTokensStore: appMain.communityTokensStore communitiesStore: appMain.communitiesStore + profileStore: appMain.profileStore devicesStore: appMain.rootStore.profileSectionStore.devicesStore currencyStore: appMain.currencyStore walletAssetsStore: appMain.walletAssetsStore @@ -1870,6 +1871,7 @@ Item { id: keycardPopupForAuthenticationOrSigning active: false sourceComponent: KeycardPopup { + myKeyUid: appMain.profileStore.keyUid sharedKeycardModule: appMain.rootStore.mainModuleInst.keycardSharedModuleForAuthenticationOrSigning } @@ -1882,6 +1884,7 @@ Item { id: keycardPopup active: false sourceComponent: KeycardPopup { + myKeyUid: appMain.profileStore.keyUid sharedKeycardModule: appMain.rootStore.mainModuleInst.keycardSharedModule } diff --git a/ui/app/mainui/Popups.qml b/ui/app/mainui/Popups.qml index 4f0f79c0d9..0c95e14012 100644 --- a/ui/app/mainui/Popups.qml +++ b/ui/app/mainui/Popups.qml @@ -43,6 +43,7 @@ QtObject { required property AppLayoutStores.RootStore rootStore required property CommunityTokensStore communityTokensStore property CommunitiesStore communitiesStore + property ProfileStores.ProfileStore profileStore property ProfileStores.DevicesStore devicesStore property CurrenciesStore currencyStore property WalletStore.WalletAssetsStore walletAssetsStore @@ -446,6 +447,9 @@ QtObject { Component { id: contactOutgoingVerificationRequestPopupComponent OutgoingContactVerificationRequestPopup { + + profileStore: root.profileStore + onVerificationRequestCanceled: { rootStore.contactStore.cancelVerificationRequest(publicKey) } diff --git a/ui/imports/shared/popups/OutgoingContactVerificationRequestPopup.qml b/ui/imports/shared/popups/OutgoingContactVerificationRequestPopup.qml index 5cbbf6776f..8371ae118b 100644 --- a/ui/imports/shared/popups/OutgoingContactVerificationRequestPopup.qml +++ b/ui/imports/shared/popups/OutgoingContactVerificationRequestPopup.qml @@ -10,9 +10,13 @@ import StatusQ.Controls 0.1 import shared.views.chat 1.0 +import AppLayouts.Profile.stores 1.0 as ProfileStores + CommonContactDialog { id: root + property ProfileStores.ProfileStore profileStore + property int verificationStatus property string verificationChallenge property string verificationResponse @@ -70,13 +74,13 @@ CommonContactDialog { id: challengeMessage timestamp: root.verificationRequestedAt messageDetails.messageText: root.verificationChallenge - messageDetails.sender.id: Global.userProfile.pubKey - messageDetails.sender.displayName: Global.userProfile.name - messageDetails.sender.profileImage.name: Global.userProfile.icon + messageDetails.sender.id: root.profileStore.pubkey + messageDetails.sender.displayName: root.profileStore.name + messageDetails.sender.profileImage.name: root.profileStore.icon messageDetails.sender.profileImage.assetSettings.isImage: true - messageDetails.sender.profileImage.colorId: Utils.colorIdForPubkey(Global.userProfile.pubKey) - messageDetails.sender.profileImage.colorHash: Utils.getColorHashAsJson(Global.userProfile.pubKey, !!Global.userProfile.preferredName) - messageDetails.sender.isEnsVerified: !!Global.userProfile.preferredName + messageDetails.sender.profileImage.colorId: Utils.colorIdForPubkey(root.profileStore.pubkey) + messageDetails.sender.profileImage.colorHash: Utils.getColorHashAsJson(root.profileStore.pubkey, !!root.profileStore.preferredName) + messageDetails.sender.isEnsVerified: !!root.profileStore.preferredName Layout.fillWidth: true } diff --git a/ui/imports/shared/popups/keycard/KeycardPopup.qml b/ui/imports/shared/popups/keycard/KeycardPopup.qml index 7593e5d0af..180faf0efe 100644 --- a/ui/imports/shared/popups/keycard/KeycardPopup.qml +++ b/ui/imports/shared/popups/keycard/KeycardPopup.qml @@ -11,6 +11,8 @@ import utils 1.0 StatusModal { id: root + property alias myKeyUid: content.myKeyUid + property var sharedKeycardModule property var emojiPopup diff --git a/ui/imports/shared/popups/keycard/KeycardPopupContent.qml b/ui/imports/shared/popups/keycard/KeycardPopupContent.qml index bce8b5ce62..bd1563e095 100644 --- a/ui/imports/shared/popups/keycard/KeycardPopupContent.qml +++ b/ui/imports/shared/popups/keycard/KeycardPopupContent.qml @@ -7,6 +7,8 @@ import "./states" Item { id: root + property string myKeyUid + property var sharedKeycardModule property var emojiPopup readonly property alias primaryButtonEnabled: d.primaryButtonEnabled @@ -158,6 +160,7 @@ Item { Component { id: confirmationComponent KeycardConfirmation { + myKeyUid: root.myKeyUid sharedKeycardModule: root.sharedKeycardModule Component.onCompleted: { diff --git a/ui/imports/shared/popups/keycard/states/KeycardConfirmation.qml b/ui/imports/shared/popups/keycard/states/KeycardConfirmation.qml index fa1fb786da..e50186081d 100644 --- a/ui/imports/shared/popups/keycard/states/KeycardConfirmation.qml +++ b/ui/imports/shared/popups/keycard/states/KeycardConfirmation.qml @@ -13,6 +13,8 @@ import "../helpers" Item { id: root + property string myKeyUid + property var sharedKeycardModule signal confirmationUpdated(bool value) @@ -73,10 +75,8 @@ Item { horizontalAlignment: Text.AlignHCenter Layout.preferredHeight: Constants.keycard.general.titleHeight text: { - // we need to check userProfile since factory reset flow is also available before user logs in the app - if (!!Global.userProfile && - !!root.sharedKeycardModule.keyPairForProcessing && - root.sharedKeycardModule.keyPairForProcessing.keyUid === Global.userProfile.keyUid) + if (!!root.sharedKeycardModule.keyPairForProcessing && + root.sharedKeycardModule.keyPairForProcessing.keyUid === root.myKeyUid) return qsTr("Warning, this Keycard stores your main Status profile and\naccounts. A factory reset will permanently delete it.") return qsTr("A factory reset will delete the key on this Keycard.\nAre you sure you want to do this?")