Utils.getCompressedPk removed from multiple components

This commit is contained in:
Michał Cieślak 2024-10-29 00:00:16 +01:00 committed by Michał
parent 0f98244e1f
commit 28f6bee90e
11 changed files with 76 additions and 49 deletions

View File

@ -26,13 +26,8 @@ SplitView {
// globalUtilsInst mock // globalUtilsInst mock
QtObject { QtObject {
function getEmojiHashAsJson(publicKey) {
return JSON.stringify(["👨🏻‍🍼", "🏃🏿‍♂️", "🌇", "🤶🏿", "🏮","🤷🏻‍♂️", "🤦🏻", "📣", "🤎", "👷🏽", "😺", "🥞", "🔃", "🧝🏽‍♂️"])
}
function getColorId(publicKey) { return colorId.value } function getColorId(publicKey) { return colorId.value }
function getCompressedPk(publicKey) { return "zx3sh" + publicKey }
function getColorHashAsJson(publicKey, skipEnsVerification=false) { function getColorHashAsJson(publicKey, skipEnsVerification=false) {
if (skipEnsVerification) if (skipEnsVerification)
return return
@ -40,16 +35,10 @@ SplitView {
{colorId: 19, segmentLength: 2}]) {colorId: 19, segmentLength: 2}])
} }
function isCompressedPubKey(publicKey) { return true }
function addTimestampToURL(url) { function addTimestampToURL(url) {
return url return url
} }
function isAlias(name) {
return false
}
Component.onCompleted: { Component.onCompleted: {
Utils.globalUtilsInst = this Utils.globalUtilsInst = this
root.globalUtilsReady = true root.globalUtilsReady = true
@ -408,6 +397,24 @@ SplitView {
logs.logEvent("contactsStore::requestProfileShowcase", ["publicKey"], arguments) 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
}
}
} }
} }
} }

View File

@ -100,7 +100,7 @@ Item {
objectName: "profileChatKeyViewChatKeyTxt" objectName: "profileChatKeyViewChatKeyTxt"
Layout.preferredHeight: 22 Layout.preferredHeight: 22
color: Theme.palette.secondaryText color: Theme.palette.secondaryText
text: qsTr("Chatkey:") + " " + Utils.getCompressedPk(d.publicKey) text: qsTr("Chatkey:") + " " + root.utilsStore.getCompressedPk(d.publicKey)
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
wrapMode: Text.WordWrap wrapMode: Text.WordWrap
Layout.alignment: Qt.AlignHCenter | Qt.AlignTop Layout.alignment: Qt.AlignHCenter | Qt.AlignTop

View File

@ -3,13 +3,15 @@ import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15 import QtQuick.Layouts 1.15
import QtQml.Models 2.15 import QtQml.Models 2.15
import StatusQ 0.1
import StatusQ.Core 0.1 import StatusQ.Core 0.1
import StatusQ.Core.Theme 0.1 import StatusQ.Core.Theme 0.1
import utils 1.0
import shared 1.0 import shared 1.0
import shared.popups 1.0
import shared.panels 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 import SortFilterProxyModel 0.2
@ -18,6 +20,7 @@ Item {
implicitHeight: (title.height + contactsList.height) implicitHeight: (title.height + contactsList.height)
property var contactsModel property var contactsModel
property SharedStores.UtilsStore utilsStore
property int panelUsage: Constants.contactsPanelUsage.unknownPosition property int panelUsage: Constants.contactsPanelUsage.unknownPosition
@ -60,14 +63,17 @@ Item {
sourceModel: root.contactsModel sourceModel: root.contactsModel
function panelUsagePredicate(isVerified) { function panelUsagePredicate(isVerified) {
if (panelUsage === Constants.contactsPanelUsage.verifiedMutualContacts) return isVerified if (panelUsage === Constants.contactsPanelUsage.verifiedMutualContacts)
if (panelUsage === Constants.contactsPanelUsage.mutualContacts) return !isVerified return isVerified
if (panelUsage === Constants.contactsPanelUsage.mutualContacts)
return !isVerified
return true return true
} }
function searchPredicate(name, pubkey) { function searchPredicate(name, pubkey) {
const lowerCaseSearchString = root.searchString.toLowerCase() const lowerCaseSearchString = root.searchString.toLowerCase()
const compressedPubkey = Utils.getCompressedPk(pubkey) const compressedPubkey = root.utilsStore.getCompressedPk(pubkey)
return name.toLowerCase().includes(lowerCaseSearchString) || return name.toLowerCase().includes(lowerCaseSearchString) ||
pubkey.toLowerCase().includes(lowerCaseSearchString) || pubkey.toLowerCase().includes(lowerCaseSearchString) ||
@ -75,7 +81,10 @@ Item {
} }
filters: [ filters: [
ExpressionFilter { expression: filteredModel.panelUsagePredicate(model.isVerified) }, FastExpressionFilter {
expression: filteredModel.panelUsagePredicate(model.isVerified)
expectedRoles: ["isVerified"]
},
ExpressionFilter { ExpressionFilter {
enabled: root.searchString !== "" enabled: root.searchString !== ""
expression: { expression: {
@ -85,12 +94,10 @@ Item {
} }
] ]
sorters: [ sorters: StringSorter {
StringSorter { roleName: "preferredDisplayName"
roleName: "preferredDisplayName" caseSensitivity: Qt.CaseInsensitive
caseSensitivity: Qt.CaseInsensitive }
}
]
} }
delegate: ContactPanel { delegate: ContactPanel {

View File

@ -168,6 +168,7 @@ SettingsContentBase {
title: qsTr("Trusted Contacts") title: qsTr("Trusted Contacts")
visible: !noFriendsItem.visible && count > 0 visible: !noFriendsItem.visible && count > 0
contactsModel: root.contactsStore.myContactsModel contactsModel: root.contactsStore.myContactsModel
utilsStore: root.utilsStore
searchString: searchBox.text searchString: searchBox.text
onOpenContactContextMenu: function (publicKey, name, icon) { onOpenContactContextMenu: function (publicKey, name, icon) {
root.openContextMenu(publicKey, name, icon) root.openContextMenu(publicKey, name, icon)
@ -184,6 +185,7 @@ SettingsContentBase {
visible: !noFriendsItem.visible && count > 0 visible: !noFriendsItem.visible && count > 0
title: qsTr("Contacts") title: qsTr("Contacts")
contactsModel: root.contactsStore.myContactsModel contactsModel: root.contactsStore.myContactsModel
utilsStore: root.utilsStore
searchString: searchBox.text searchString: searchBox.text
onOpenContactContextMenu: function (publicKey, name, icon) { onOpenContactContextMenu: function (publicKey, name, icon) {
root.openContextMenu(publicKey, name, icon) root.openContextMenu(publicKey, name, icon)
@ -230,6 +232,7 @@ SettingsContentBase {
root.openContextMenu(publicKey, name, icon) root.openContextMenu(publicKey, name, icon)
} }
contactsModel: root.contactsStore.receivedContactRequestsModel contactsModel: root.contactsStore.receivedContactRequestsModel
utilsStore: root.utilsStore
panelUsage: Constants.contactsPanelUsage.receivedContactRequest panelUsage: Constants.contactsPanelUsage.receivedContactRequest
onSendMessageActionTriggered: { onSendMessageActionTriggered: {
@ -256,6 +259,7 @@ SettingsContentBase {
root.openContextMenu(publicKey, name, icon) root.openContextMenu(publicKey, name, icon)
} }
contactsModel: root.contactsStore.sentContactRequestsModel contactsModel: root.contactsStore.sentContactRequestsModel
utilsStore: root.utilsStore
panelUsage: Constants.contactsPanelUsage.sentContactRequest panelUsage: Constants.contactsPanelUsage.sentContactRequest
} }
} }
@ -314,6 +318,7 @@ SettingsContentBase {
root.openContextMenu(publicKey, name, icon) root.openContextMenu(publicKey, name, icon)
} }
contactsModel: root.contactsStore.blockedContactsModel contactsModel: root.contactsStore.blockedContactsModel
utilsStore: root.utilsStore
panelUsage: Constants.contactsPanelUsage.blockedContacts panelUsage: Constants.contactsPanelUsage.blockedContacts
visible: (stackLayout.currentIndex === 2) visible: (stackLayout.currentIndex === 2)
onVisibleChanged: { onVisibleChanged: {

View File

@ -7,12 +7,11 @@ import utils 1.0
import shared 1.0 import shared 1.0
import shared.panels 1.0 import shared.panels 1.0
import shared.popups 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.validators 1.0
import shared.controls.chat 1.0 import shared.controls.chat 1.0
import "../popups" import "../popups"
import "../stores"
import "../controls" import "../controls"
import "./profile" import "./profile"
@ -22,18 +21,19 @@ import StatusQ.Core.Utils 0.1
import StatusQ.Components 0.1 import StatusQ.Components 0.1
import StatusQ.Controls 0.1 import StatusQ.Controls 0.1
import AppLayouts.Communities.stores 1.0 as CommunitiesStores
import AppLayouts.Profile.helpers 1.0 import AppLayouts.Profile.helpers 1.0
import AppLayouts.Profile.panels 1.0 import AppLayouts.Profile.panels 1.0
import AppLayouts.Wallet.stores 1.0 import AppLayouts.Profile.stores 1.0 as ProfileStores
import AppLayouts.Communities.stores 1.0 import AppLayouts.Wallet.stores 1.0 as WalletStores
SettingsContentBase { SettingsContentBase {
id: root id: root
property ProfileStore profileStore property ProfileStores.ProfileStore profileStore
property ContactsStore contactsStore property ProfileStores.ContactsStore contactsStore
property CommunitiesStore communitiesStore property CommunitiesStores.CommunitiesStore communitiesStore
property UtilsStore utilsStore property SharedStores.UtilsStore utilsStore
property bool sendToAccountEnabled: false property bool sendToAccountEnabled: false
@ -406,6 +406,7 @@ SettingsContentBase {
publicKey: root.contactsStore.myPublicKey publicKey: root.contactsStore.myPublicKey
profileStore: root.profileStore profileStore: root.profileStore
contactsStore: root.contactsStore contactsStore: root.contactsStore
walletStore: WalletStores.RootStore
utilsStore: root.utilsStore utilsStore: root.utilsStore
sendToAccountEnabled: root.sendToAccountEnabled sendToAccountEnabled: root.sendToAccountEnabled
onClosed: destroy() onClosed: destroy()

View File

@ -2,11 +2,11 @@ import QtQuick 2.15
import QtQuick.Layouts 1.15 import QtQuick.Layouts 1.15
import QtGraphicalEffects 1.15 import QtGraphicalEffects 1.15
import shared.views 1.0 as SharedViews
import StatusQ.Core.Theme 0.1 import StatusQ.Core.Theme 0.1
import AppLayouts.Wallet.stores 1.0 as WalletStores
import shared.controls 1.0 import shared.controls 1.0
import shared.views 1.0 as SharedViews
Item { Item {
property alias profileStore: profilePreview.profileStore property alias profileStore: profilePreview.profileStore
@ -51,9 +51,13 @@ Item {
SharedViews.ProfileDialogView { SharedViews.ProfileDialogView {
id: profilePreview id: profilePreview
Layout.fillWidth: true Layout.fillWidth: true
Layout.fillHeight: true Layout.fillHeight: true
Layout.maximumHeight: implicitHeight Layout.maximumHeight: implicitHeight
walletStore: WalletStores.RootStore
readOnly: true readOnly: true
} }
Item { Layout.fillHeight: true } Item { Layout.fillHeight: true }

View File

@ -25,7 +25,7 @@ import AppLayouts.Wallet.popups.buy 1.0
import AppLayouts.Wallet.popups 1.0 import AppLayouts.Wallet.popups 1.0
import AppLayouts.Communities.stores 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 AppLayouts.Chat.stores 1.0 as ChatStores
import shared.popups 1.0 import shared.popups 1.0
@ -51,10 +51,10 @@ QtObject {
property ProfileStores.ProfileStore profileStore property ProfileStores.ProfileStore profileStore
property ProfileStores.DevicesStore devicesStore property ProfileStores.DevicesStore devicesStore
property CurrenciesStore currencyStore property CurrenciesStore currencyStore
property WalletStore.WalletAssetsStore walletAssetsStore property WalletStores.WalletAssetsStore walletAssetsStore
property WalletStore.CollectiblesStore walletCollectiblesStore property WalletStores.CollectiblesStore walletCollectiblesStore
property NetworkConnectionStore networkConnectionStore property NetworkConnectionStore networkConnectionStore
property WalletStore.BuyCryptoStore buyCryptoStore property WalletStores.BuyCryptoStore buyCryptoStore
property bool isDevBuild property bool isDevBuild
signal openExternalLink(string link) signal openExternalLink(string link)
@ -528,6 +528,7 @@ QtObject {
profileStore: rootStore.profileSectionStore.profileStore profileStore: rootStore.profileSectionStore.profileStore
contactsStore: rootStore.profileSectionStore.contactsStore contactsStore: rootStore.profileSectionStore.contactsStore
walletStore: WalletStores.RootStore
utilsStore: root.utilsStore utilsStore: root.utilsStore
sendToAccountEnabled: root.networkConnectionStore.sendBuyBridgeEnabled sendToAccountEnabled: root.networkConnectionStore.sendBuyBridgeEnabled
@ -695,9 +696,9 @@ QtObject {
joinPermissionsCheckCompletedWithoutErrors: root.rootStore.joinPermissionsCheckCompletedWithoutErrors joinPermissionsCheckCompletedWithoutErrors: root.rootStore.joinPermissionsCheckCompletedWithoutErrors
walletAccountsModel: root.rootStore.walletAccountsModel 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 walletAssetsModel: walletAssetsStore.groupedAccountAssetsModel
permissionsModel: { permissionsModel: {
@ -947,12 +948,12 @@ QtObject {
introMessage: chatStore.sectionDetails.introMessage introMessage: chatStore.sectionDetails.introMessage
canProfileProveOwnershipOfProvidedAddressesFn: WalletStore.RootStore.canProfileProveOwnershipOfProvidedAddresses canProfileProveOwnershipOfProvidedAddressesFn: WalletStores.RootStore.canProfileProveOwnershipOfProvidedAddresses
walletAccountsModel: root.rootStore.walletAccountsModel walletAccountsModel: root.rootStore.walletAccountsModel
walletAssetsModel: walletAssetsStore.groupedAccountAssetsModel walletAssetsModel: walletAssetsStore.groupedAccountAssetsModel
walletCollectiblesModel: WalletStore.RootStore.collectiblesStore.allCollectiblesModel walletCollectiblesModel: WalletStores.RootStore.collectiblesStore.allCollectiblesModel
permissionsModel: { permissionsModel: {
root.rootStore.prepareTokenModelForCommunity(editSharedAddressesPopup.communityId) root.rootStore.prepareTokenModelForCommunity(editSharedAddressesPopup.communityId)
@ -1054,7 +1055,7 @@ QtObject {
feeErrorText: feeSubscriber.feeErrorText feeErrorText: feeSubscriber.feeErrorText
isFeeLoading: !feeSubscriber.feesResponse isFeeLoading: !feeSubscriber.feesResponse
accounts: WalletStore.RootStore.nonWatchAccounts accounts: WalletStores.RootStore.nonWatchAccounts
destroyOnClose: true destroyOnClose: true
@ -1200,7 +1201,7 @@ QtObject {
id: swapModal id: swapModal
SwapModal { SwapModal {
swapAdaptor: SwapModalAdaptor { swapAdaptor: SwapModalAdaptor {
swapStore: WalletStore.SwapStore {} swapStore: WalletStores.SwapStore {}
walletAssetsStore: root.walletAssetsStore walletAssetsStore: root.walletAssetsStore
currencyStore: root.currencyStore currencyStore: root.currencyStore
swapFormData: swapInputParamsForm swapFormData: swapInputParamsForm

View File

@ -110,7 +110,7 @@ StatusDialog {
id: keyHoverHandler id: keyHoverHandler
} }
StatusToolTip { StatusToolTip {
text: Utils.getCompressedPk(root.publicKey) text: root.utilsStore.getCompressedPk(root.publicKey)
visible: keyHoverHandler.hovered visible: keyHoverHandler.hovered
} }
} }

View File

@ -15,6 +15,7 @@ StatusDialog {
property alias profileStore: profileView.profileStore property alias profileStore: profileView.profileStore
property alias contactsStore: profileView.contactsStore property alias contactsStore: profileView.contactsStore
property alias walletStore: profileView.walletStore
property alias utilsStore: profileView.utilsStore property alias utilsStore: profileView.utilsStore
property alias sendToAccountEnabled: profileView.sendToAccountEnabled property alias sendToAccountEnabled: profileView.sendToAccountEnabled

View File

@ -38,6 +38,7 @@ Pane {
property ProfileStores.ProfileStore profileStore property ProfileStores.ProfileStore profileStore
property ProfileStores.ContactsStore contactsStore property ProfileStores.ContactsStore contactsStore
property SharedStores.UtilsStore utilsStore property SharedStores.UtilsStore utilsStore
property WalletStores.RootStore walletStore
property alias sendToAccountEnabled: showcaseView.sendToAccountEnabled property alias sendToAccountEnabled: showcaseView.sendToAccountEnabled
@ -448,7 +449,7 @@ Pane {
id: keyHoverHandler id: keyHoverHandler
} }
StatusToolTip { StatusToolTip {
text: Utils.getCompressedPk(root.publicKey) text: root.utilsStore.getCompressedPk(root.publicKey)
visible: keyHoverHandler.hovered visible: keyHoverHandler.hovered
} }
} }
@ -456,7 +457,7 @@ Pane {
Layout.leftMargin: -4 Layout.leftMargin: -4
Layout.preferredWidth: 16 Layout.preferredWidth: 16
Layout.preferredHeight: 16 Layout.preferredHeight: 16
textToCopy: Utils.getCompressedPk(root.publicKey) textToCopy: root.utilsStore.getCompressedPk(root.publicKey)
StatusToolTip { StatusToolTip {
text: qsTr("Copy Chat Key") text: qsTr("Copy Chat Key")
visible: parent.hovered visible: parent.hovered
@ -549,7 +550,7 @@ Pane {
socialLinksModel: root.showcaseSocialLinksModel socialLinksModel: root.showcaseSocialLinksModel
// assetsModel: root.showcaseAssetsModel // assetsModel: root.showcaseAssetsModel
walletStore: WalletStores.RootStore walletStore: root.walletStore
onCloseRequested: root.closeRequested() onCloseRequested: root.closeRequested()
onCopyToClipboard: ClipboardUtils.setText(text) onCopyToClipboard: ClipboardUtils.setText(text)

View File

@ -846,7 +846,7 @@ Loader {
albumCount: root.albumCount albumCount: root.albumCount
amISender: root.amISender 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.displayName: root.senderDisplayName
sender.secondaryName: root.senderOptionalName sender.secondaryName: root.senderOptionalName
sender.isEnsVerified: root.isBridgeMessage ? false : root.senderIsEnsVerified sender.isEnsVerified: root.isBridgeMessage ? false : root.senderIsEnsVerified