From 28f6bee90e9bbaef7c2ccd57f99231a4dfe91b8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Cie=C5=9Blak?= Date: Tue, 29 Oct 2024 00:00:16 +0100 Subject: [PATCH] Utils.getCompressedPk removed from multiple components --- storybook/pages/ProfileDialogViewPage.qml | 29 ++++++++++------- .../Onboarding/views/ProfileChatKeyView.qml | 2 +- .../Profile/panels/ContactsListPanel.qml | 31 ++++++++++++------- .../AppLayouts/Profile/views/ContactsView.qml | 5 +++ .../Profile/views/MyProfileView.qml | 17 +++++----- .../views/profile/MyProfilePreview.qml | 8 +++-- ui/app/mainui/Popups.qml | 21 +++++++------ .../shared/popups/CommonContactDialog.qml | 2 +- ui/imports/shared/popups/ProfileDialog.qml | 1 + ui/imports/shared/views/ProfileDialogView.qml | 7 +++-- ui/imports/shared/views/chat/MessageView.qml | 2 +- 11 files changed, 76 insertions(+), 49 deletions(-) diff --git a/storybook/pages/ProfileDialogViewPage.qml b/storybook/pages/ProfileDialogViewPage.qml index ade3a0f2a0..973b7faf08 100644 --- a/storybook/pages/ProfileDialogViewPage.qml +++ b/storybook/pages/ProfileDialogViewPage.qml @@ -26,13 +26,8 @@ SplitView { // globalUtilsInst mock QtObject { - function getEmojiHashAsJson(publicKey) { - return JSON.stringify(["👨🏻‍🍼", "🏃🏿‍♂️", "🌇", "🤶🏿", "🏮","🤷🏻‍♂️", "🤦🏻", "📣", "🤎", "👷🏽", "😺", "🥞", "🔃", "🧝🏽‍♂️"]) - } function getColorId(publicKey) { return colorId.value } - function getCompressedPk(publicKey) { return "zx3sh" + publicKey } - function getColorHashAsJson(publicKey, skipEnsVerification=false) { if (skipEnsVerification) return @@ -40,16 +35,10 @@ SplitView { {colorId: 19, segmentLength: 2}]) } - function isCompressedPubKey(publicKey) { return true } - function addTimestampToURL(url) { return url } - function isAlias(name) { - return false - } - Component.onCompleted: { Utils.globalUtilsInst = this root.globalUtilsReady = true @@ -408,6 +397,24 @@ SplitView { logs.logEvent("contactsStore::requestProfileShowcase", ["publicKey"], arguments) } } + + utilsStore: SharedStores.UtilsStore { + function getEmojiHash(publicKey) { + return ["👨🏻‍🍼", "🏃🏿‍♂️", "🌇", "🤶🏿", "🏮","🤷🏻‍♂️", "🤦🏻", + "📣", "🤎", "👷🏽", "😺", "🥞", "🔃", "🧝🏽‍♂️"] + } + + function getCompressedPk(publicKey) { return "zx3sh" + publicKey } + + + function isCompressedPubKey(publicKey) { return true } + + function isAlias(name) { + return false + } + + + } } } } diff --git a/ui/app/AppLayouts/Onboarding/views/ProfileChatKeyView.qml b/ui/app/AppLayouts/Onboarding/views/ProfileChatKeyView.qml index b6686f117a..054d230176 100644 --- a/ui/app/AppLayouts/Onboarding/views/ProfileChatKeyView.qml +++ b/ui/app/AppLayouts/Onboarding/views/ProfileChatKeyView.qml @@ -100,7 +100,7 @@ Item { objectName: "profileChatKeyViewChatKeyTxt" Layout.preferredHeight: 22 color: Theme.palette.secondaryText - text: qsTr("Chatkey:") + " " + Utils.getCompressedPk(d.publicKey) + text: qsTr("Chatkey:") + " " + root.utilsStore.getCompressedPk(d.publicKey) horizontalAlignment: Text.AlignHCenter wrapMode: Text.WordWrap Layout.alignment: Qt.AlignHCenter | Qt.AlignTop diff --git a/ui/app/AppLayouts/Profile/panels/ContactsListPanel.qml b/ui/app/AppLayouts/Profile/panels/ContactsListPanel.qml index 3c9c864986..e0bda974f9 100644 --- a/ui/app/AppLayouts/Profile/panels/ContactsListPanel.qml +++ b/ui/app/AppLayouts/Profile/panels/ContactsListPanel.qml @@ -3,13 +3,15 @@ import QtQuick.Controls 2.15 import QtQuick.Layouts 1.15 import QtQml.Models 2.15 +import StatusQ 0.1 import StatusQ.Core 0.1 import StatusQ.Core.Theme 0.1 -import utils 1.0 import shared 1.0 -import shared.popups 1.0 import shared.panels 1.0 +import shared.popups 1.0 +import shared.stores 1.0 as SharedStores +import utils 1.0 import SortFilterProxyModel 0.2 @@ -18,6 +20,7 @@ Item { implicitHeight: (title.height + contactsList.height) property var contactsModel + property SharedStores.UtilsStore utilsStore property int panelUsage: Constants.contactsPanelUsage.unknownPosition @@ -60,14 +63,17 @@ Item { sourceModel: root.contactsModel function panelUsagePredicate(isVerified) { - if (panelUsage === Constants.contactsPanelUsage.verifiedMutualContacts) return isVerified - if (panelUsage === Constants.contactsPanelUsage.mutualContacts) return !isVerified + if (panelUsage === Constants.contactsPanelUsage.verifiedMutualContacts) + return isVerified + if (panelUsage === Constants.contactsPanelUsage.mutualContacts) + return !isVerified + return true } function searchPredicate(name, pubkey) { const lowerCaseSearchString = root.searchString.toLowerCase() - const compressedPubkey = Utils.getCompressedPk(pubkey) + const compressedPubkey = root.utilsStore.getCompressedPk(pubkey) return name.toLowerCase().includes(lowerCaseSearchString) || pubkey.toLowerCase().includes(lowerCaseSearchString) || @@ -75,7 +81,10 @@ Item { } filters: [ - ExpressionFilter { expression: filteredModel.panelUsagePredicate(model.isVerified) }, + FastExpressionFilter { + expression: filteredModel.panelUsagePredicate(model.isVerified) + expectedRoles: ["isVerified"] + }, ExpressionFilter { enabled: root.searchString !== "" expression: { @@ -85,12 +94,10 @@ Item { } ] - sorters: [ - StringSorter { - roleName: "preferredDisplayName" - caseSensitivity: Qt.CaseInsensitive - } - ] + sorters: StringSorter { + roleName: "preferredDisplayName" + caseSensitivity: Qt.CaseInsensitive + } } delegate: ContactPanel { diff --git a/ui/app/AppLayouts/Profile/views/ContactsView.qml b/ui/app/AppLayouts/Profile/views/ContactsView.qml index 97ad956250..321ca64a97 100644 --- a/ui/app/AppLayouts/Profile/views/ContactsView.qml +++ b/ui/app/AppLayouts/Profile/views/ContactsView.qml @@ -168,6 +168,7 @@ SettingsContentBase { title: qsTr("Trusted Contacts") visible: !noFriendsItem.visible && count > 0 contactsModel: root.contactsStore.myContactsModel + utilsStore: root.utilsStore searchString: searchBox.text onOpenContactContextMenu: function (publicKey, name, icon) { root.openContextMenu(publicKey, name, icon) @@ -184,6 +185,7 @@ SettingsContentBase { visible: !noFriendsItem.visible && count > 0 title: qsTr("Contacts") contactsModel: root.contactsStore.myContactsModel + utilsStore: root.utilsStore searchString: searchBox.text onOpenContactContextMenu: function (publicKey, name, icon) { root.openContextMenu(publicKey, name, icon) @@ -230,6 +232,7 @@ SettingsContentBase { root.openContextMenu(publicKey, name, icon) } contactsModel: root.contactsStore.receivedContactRequestsModel + utilsStore: root.utilsStore panelUsage: Constants.contactsPanelUsage.receivedContactRequest onSendMessageActionTriggered: { @@ -256,6 +259,7 @@ SettingsContentBase { root.openContextMenu(publicKey, name, icon) } contactsModel: root.contactsStore.sentContactRequestsModel + utilsStore: root.utilsStore panelUsage: Constants.contactsPanelUsage.sentContactRequest } } @@ -314,6 +318,7 @@ SettingsContentBase { root.openContextMenu(publicKey, name, icon) } contactsModel: root.contactsStore.blockedContactsModel + utilsStore: root.utilsStore panelUsage: Constants.contactsPanelUsage.blockedContacts visible: (stackLayout.currentIndex === 2) onVisibleChanged: { diff --git a/ui/app/AppLayouts/Profile/views/MyProfileView.qml b/ui/app/AppLayouts/Profile/views/MyProfileView.qml index 95ffc174e0..293c637713 100644 --- a/ui/app/AppLayouts/Profile/views/MyProfileView.qml +++ b/ui/app/AppLayouts/Profile/views/MyProfileView.qml @@ -7,12 +7,11 @@ import utils 1.0 import shared 1.0 import shared.panels 1.0 import shared.popups 1.0 -import shared.stores 1.0 +import shared.stores 1.0 as SharedStores import shared.validators 1.0 import shared.controls.chat 1.0 import "../popups" -import "../stores" import "../controls" import "./profile" @@ -22,18 +21,19 @@ import StatusQ.Core.Utils 0.1 import StatusQ.Components 0.1 import StatusQ.Controls 0.1 +import AppLayouts.Communities.stores 1.0 as CommunitiesStores import AppLayouts.Profile.helpers 1.0 import AppLayouts.Profile.panels 1.0 -import AppLayouts.Wallet.stores 1.0 -import AppLayouts.Communities.stores 1.0 +import AppLayouts.Profile.stores 1.0 as ProfileStores +import AppLayouts.Wallet.stores 1.0 as WalletStores SettingsContentBase { id: root - property ProfileStore profileStore - property ContactsStore contactsStore - property CommunitiesStore communitiesStore - property UtilsStore utilsStore + property ProfileStores.ProfileStore profileStore + property ProfileStores.ContactsStore contactsStore + property CommunitiesStores.CommunitiesStore communitiesStore + property SharedStores.UtilsStore utilsStore property bool sendToAccountEnabled: false @@ -406,6 +406,7 @@ SettingsContentBase { publicKey: root.contactsStore.myPublicKey profileStore: root.profileStore contactsStore: root.contactsStore + walletStore: WalletStores.RootStore utilsStore: root.utilsStore sendToAccountEnabled: root.sendToAccountEnabled onClosed: destroy() diff --git a/ui/app/AppLayouts/Profile/views/profile/MyProfilePreview.qml b/ui/app/AppLayouts/Profile/views/profile/MyProfilePreview.qml index e39e11e2f1..5b0426af59 100644 --- a/ui/app/AppLayouts/Profile/views/profile/MyProfilePreview.qml +++ b/ui/app/AppLayouts/Profile/views/profile/MyProfilePreview.qml @@ -2,11 +2,11 @@ import QtQuick 2.15 import QtQuick.Layouts 1.15 import QtGraphicalEffects 1.15 -import shared.views 1.0 as SharedViews - import StatusQ.Core.Theme 0.1 +import AppLayouts.Wallet.stores 1.0 as WalletStores import shared.controls 1.0 +import shared.views 1.0 as SharedViews Item { property alias profileStore: profilePreview.profileStore @@ -51,9 +51,13 @@ Item { SharedViews.ProfileDialogView { id: profilePreview + Layout.fillWidth: true Layout.fillHeight: true Layout.maximumHeight: implicitHeight + + walletStore: WalletStores.RootStore + readOnly: true } Item { Layout.fillHeight: true } diff --git a/ui/app/mainui/Popups.qml b/ui/app/mainui/Popups.qml index c2fe9e74f7..f09bcf3f81 100644 --- a/ui/app/mainui/Popups.qml +++ b/ui/app/mainui/Popups.qml @@ -25,7 +25,7 @@ import AppLayouts.Wallet.popups.buy 1.0 import AppLayouts.Wallet.popups 1.0 import AppLayouts.Communities.stores 1.0 -import AppLayouts.Wallet.stores 1.0 as WalletStore +import AppLayouts.Wallet.stores 1.0 as WalletStores import AppLayouts.Chat.stores 1.0 as ChatStores import shared.popups 1.0 @@ -51,10 +51,10 @@ QtObject { property ProfileStores.ProfileStore profileStore property ProfileStores.DevicesStore devicesStore property CurrenciesStore currencyStore - property WalletStore.WalletAssetsStore walletAssetsStore - property WalletStore.CollectiblesStore walletCollectiblesStore + property WalletStores.WalletAssetsStore walletAssetsStore + property WalletStores.CollectiblesStore walletCollectiblesStore property NetworkConnectionStore networkConnectionStore - property WalletStore.BuyCryptoStore buyCryptoStore + property WalletStores.BuyCryptoStore buyCryptoStore property bool isDevBuild signal openExternalLink(string link) @@ -528,6 +528,7 @@ QtObject { profileStore: rootStore.profileSectionStore.profileStore contactsStore: rootStore.profileSectionStore.contactsStore + walletStore: WalletStores.RootStore utilsStore: root.utilsStore sendToAccountEnabled: root.networkConnectionStore.sendBuyBridgeEnabled @@ -695,9 +696,9 @@ QtObject { joinPermissionsCheckCompletedWithoutErrors: root.rootStore.joinPermissionsCheckCompletedWithoutErrors walletAccountsModel: root.rootStore.walletAccountsModel - walletCollectiblesModel: WalletStore.RootStore.collectiblesStore.allCollectiblesModel + walletCollectiblesModel: WalletStores.RootStore.collectiblesStore.allCollectiblesModel - canProfileProveOwnershipOfProvidedAddressesFn: WalletStore.RootStore.canProfileProveOwnershipOfProvidedAddresses + canProfileProveOwnershipOfProvidedAddressesFn: WalletStores.RootStore.canProfileProveOwnershipOfProvidedAddresses walletAssetsModel: walletAssetsStore.groupedAccountAssetsModel permissionsModel: { @@ -947,12 +948,12 @@ QtObject { introMessage: chatStore.sectionDetails.introMessage - canProfileProveOwnershipOfProvidedAddressesFn: WalletStore.RootStore.canProfileProveOwnershipOfProvidedAddresses + canProfileProveOwnershipOfProvidedAddressesFn: WalletStores.RootStore.canProfileProveOwnershipOfProvidedAddresses walletAccountsModel: root.rootStore.walletAccountsModel walletAssetsModel: walletAssetsStore.groupedAccountAssetsModel - walletCollectiblesModel: WalletStore.RootStore.collectiblesStore.allCollectiblesModel + walletCollectiblesModel: WalletStores.RootStore.collectiblesStore.allCollectiblesModel permissionsModel: { root.rootStore.prepareTokenModelForCommunity(editSharedAddressesPopup.communityId) @@ -1054,7 +1055,7 @@ QtObject { feeErrorText: feeSubscriber.feeErrorText isFeeLoading: !feeSubscriber.feesResponse - accounts: WalletStore.RootStore.nonWatchAccounts + accounts: WalletStores.RootStore.nonWatchAccounts destroyOnClose: true @@ -1200,7 +1201,7 @@ QtObject { id: swapModal SwapModal { swapAdaptor: SwapModalAdaptor { - swapStore: WalletStore.SwapStore {} + swapStore: WalletStores.SwapStore {} walletAssetsStore: root.walletAssetsStore currencyStore: root.currencyStore swapFormData: swapInputParamsForm diff --git a/ui/imports/shared/popups/CommonContactDialog.qml b/ui/imports/shared/popups/CommonContactDialog.qml index 0c5c00fd6d..25c4d84f36 100644 --- a/ui/imports/shared/popups/CommonContactDialog.qml +++ b/ui/imports/shared/popups/CommonContactDialog.qml @@ -110,7 +110,7 @@ StatusDialog { id: keyHoverHandler } StatusToolTip { - text: Utils.getCompressedPk(root.publicKey) + text: root.utilsStore.getCompressedPk(root.publicKey) visible: keyHoverHandler.hovered } } diff --git a/ui/imports/shared/popups/ProfileDialog.qml b/ui/imports/shared/popups/ProfileDialog.qml index 92aad6dcaf..965367c2a2 100644 --- a/ui/imports/shared/popups/ProfileDialog.qml +++ b/ui/imports/shared/popups/ProfileDialog.qml @@ -15,6 +15,7 @@ StatusDialog { property alias profileStore: profileView.profileStore property alias contactsStore: profileView.contactsStore + property alias walletStore: profileView.walletStore property alias utilsStore: profileView.utilsStore property alias sendToAccountEnabled: profileView.sendToAccountEnabled diff --git a/ui/imports/shared/views/ProfileDialogView.qml b/ui/imports/shared/views/ProfileDialogView.qml index 753790646f..1d23979d22 100644 --- a/ui/imports/shared/views/ProfileDialogView.qml +++ b/ui/imports/shared/views/ProfileDialogView.qml @@ -38,6 +38,7 @@ Pane { property ProfileStores.ProfileStore profileStore property ProfileStores.ContactsStore contactsStore property SharedStores.UtilsStore utilsStore + property WalletStores.RootStore walletStore property alias sendToAccountEnabled: showcaseView.sendToAccountEnabled @@ -448,7 +449,7 @@ Pane { id: keyHoverHandler } StatusToolTip { - text: Utils.getCompressedPk(root.publicKey) + text: root.utilsStore.getCompressedPk(root.publicKey) visible: keyHoverHandler.hovered } } @@ -456,7 +457,7 @@ Pane { Layout.leftMargin: -4 Layout.preferredWidth: 16 Layout.preferredHeight: 16 - textToCopy: Utils.getCompressedPk(root.publicKey) + textToCopy: root.utilsStore.getCompressedPk(root.publicKey) StatusToolTip { text: qsTr("Copy Chat Key") visible: parent.hovered @@ -549,7 +550,7 @@ Pane { socialLinksModel: root.showcaseSocialLinksModel // assetsModel: root.showcaseAssetsModel - walletStore: WalletStores.RootStore + walletStore: root.walletStore onCloseRequested: root.closeRequested() onCopyToClipboard: ClipboardUtils.setText(text) diff --git a/ui/imports/shared/views/chat/MessageView.qml b/ui/imports/shared/views/chat/MessageView.qml index 81155c209d..48b138c869 100644 --- a/ui/imports/shared/views/chat/MessageView.qml +++ b/ui/imports/shared/views/chat/MessageView.qml @@ -846,7 +846,7 @@ Loader { albumCount: root.albumCount amISender: root.amISender - sender.id: root.senderIsEnsVerified ? "" : Utils.getCompressedPk(root.senderId) + sender.id: root.senderIsEnsVerified ? "" : root.utilsStore.getCompressedPk(root.senderId) sender.displayName: root.senderDisplayName sender.secondaryName: root.senderOptionalName sender.isEnsVerified: root.isBridgeMessage ? false : root.senderIsEnsVerified