diff --git a/storybook/pages/InviteFriendsToCommunityPopupPage.qml b/storybook/pages/InviteFriendsToCommunityPopupPage.qml index b69e342dd6..add9ebafd6 100644 --- a/storybook/pages/InviteFriendsToCommunityPopupPage.qml +++ b/storybook/pages/InviteFriendsToCommunityPopupPage.qml @@ -13,12 +13,9 @@ SplitView { Logs { id: logs } - property bool globalUtilsReady: false - property bool mainModuleReady: false property bool communitiesModuleReady: false Item { - SplitView.fillWidth: true SplitView.fillHeight: true @@ -33,46 +30,6 @@ SplitView { onClicked: loader.item.open() } - QtObject { - function getCompressedPk(publicKey) { - return "compressed" - } - - function isCompressedPubKey() { - return true - } - - function getColorHashAsJson(publicKey) { - return JSON.stringify([{colorId: 0, segmentLength: 1}, - {colorId: 19, segmentLength: 2}]) - } - - Component.onCompleted: { - Utils.globalUtilsInst = this - globalUtilsReady = true - - } - Component.onDestruction: { - globalUtilsReady = false - Utils.globalUtilsInst = {} - } - } - - QtObject { - function getContactDetailsAsJson() { - return JSON.stringify({}) - } - - Component.onCompleted: { - mainModuleReady = true - Utils.mainModuleInst = this - } - Component.onDestruction: { - mainModuleReady = false - Utils.mainModuleInst = {} - } - } - QtObject { function shareCommunityUrlWithData(communityId) { return "status-app:/"+communityId @@ -90,7 +47,7 @@ SplitView { Loader { id: loader - active: globalUtilsReady && mainModuleReady && communitiesModuleReady + active: communitiesModuleReady anchors.fill: parent sourceComponent: InviteFriendsToCommunityPopup { @@ -132,7 +89,13 @@ SplitView { isContact: true, localNickname: "", onlineStatus: 1, - pubKey: key + pubKey: key, + compressedKey: "zx3sh" + key, + colorHash: [ + { colorId: i, segmentLength: i % 5 }, + { colorId: i + 5, segmentLength: 3 }, + { colorId: 19, segmentLength: 2 } + ] }) } } diff --git a/storybook/pages/ProfilePopupInviteFriendsPanelPage.qml b/storybook/pages/ProfilePopupInviteFriendsPanelPage.qml index 177fadd6a1..8abe6afc03 100644 --- a/storybook/pages/ProfilePopupInviteFriendsPanelPage.qml +++ b/storybook/pages/ProfilePopupInviteFriendsPanelPage.qml @@ -2,90 +2,45 @@ import QtQuick 2.15 import QtQuick.Controls 2.15 import AppLayouts.Communities.panels 1.0 -import AppLayouts.Profile.stores 1.0 as ProfileStores import AppLayouts.stores 1.0 as AppLayoutStores -import utils 1.0 - Item { - property bool globalUtilsReady: false - property bool mainModuleReady: false - - QtObject { - function isCompressedPubKey(publicKey) { - return true - } - - function getCompressedPk(publicKey) { return "zx3sh" + publicKey } - - function getColorHashAsJson(publicKey) { - return JSON.stringify([{colorId: 0, segmentLength: 1}, - {colorId: 19, segmentLength: 2}]) - } - - Component.onCompleted: { - Utils.globalUtilsInst = this - globalUtilsReady = true - - } - Component.onDestruction: { - globalUtilsReady = false - Utils.globalUtilsInst = {} - } - } - - QtObject { - function getContactDetailsAsJson() { - return JSON.stringify({}) - } - - Component.onCompleted: { - mainModuleReady = true - Utils.mainModuleInst = this - } - Component.onDestruction: { - mainModuleReady = false - Utils.mainModuleInst = {} - } - } - Frame { anchors.centerIn: parent - Loader { - active: globalUtilsReady && mainModuleReady - sourceComponent: ProfilePopupInviteFriendsPanel { - id: panel + ProfilePopupInviteFriendsPanel { + communityId: "communityId" - communityId: "communityId" - - rootStore: AppLayoutStores.RootStore { - function communityHasMember(communityId, pubKey) { - return false - } + rootStore: AppLayoutStores.RootStore { + function communityHasMember(communityId, pubKey) { + return false } + } - contactsStore: ProfileStores.ContactsStore { - readonly property ListModel myContactsModel: ListModel { - Component.onCompleted: { - const keys = [] + contactsModel: ListModel { + Component.onCompleted: { + const keys = [] - for (let i = 0; i < 20; i++) { - const key = `pub_key_${i}` + for (let i = 0; i < 20; i++) { + const key = `pub_key_${i}` - append({ - alias: "", - colorId: "1", - displayName: `contact ${i}`, - ensName: "", - icon: "", - isContact: true, - localNickname: "", - onlineStatus: 1, - pubKey: key - }) - } - } + append({ + alias: "", + colorId: "1", + displayName: `contact ${i}`, + ensName: "", + icon: "", + isContact: true, + localNickname: "", + onlineStatus: 1, + pubKey: key, + compressedKey: "zx3sh" + key, + colorHash: [ + { colorId: i, segmentLength: i % 5 }, + { colorId: i + 5, segmentLength: 3 }, + { colorId: 19, segmentLength: 2 } + ] + }) } } } diff --git a/storybook/pages/ProfilePopupInviteMessagePanelPage.qml b/storybook/pages/ProfilePopupInviteMessagePanelPage.qml index 8ced8173ce..799f536988 100644 --- a/storybook/pages/ProfilePopupInviteMessagePanelPage.qml +++ b/storybook/pages/ProfilePopupInviteMessagePanelPage.qml @@ -1,91 +1,46 @@ -import QtQuick 2.14 -import QtQuick.Controls 2.14 +import QtQuick 2.15 +import QtQuick.Controls 2.15 import AppLayouts.Communities.panels 1.0 -import AppLayouts.Profile.stores 1.0 as ProfileStores - -import utils 1.0 Item { - property bool globalUtilsReady: false - property bool mainModuleReady: false - - QtObject { - function getCompressedPk(publicKey) { - return "compressed" - } - - function isCompressedPubKey() { - return true - } - - function getColorHashAsJson(publicKey) { - return JSON.stringify([{colorId: 0, segmentLength: 1}, - {colorId: 19, segmentLength: 2}]) - } - - Component.onCompleted: { - Utils.globalUtilsInst = this - globalUtilsReady = true - } - - Component.onDestruction: { - globalUtilsReady = false - Utils.globalUtilsInst = {} - } - } - - QtObject { - function getContactDetailsAsJson() { - return JSON.stringify({}) - } - - Component.onCompleted: { - Utils.mainModuleInst = this - mainModuleReady = true - } - - Component.onDestruction: { - mainModuleReady = false - Utils.mainModuleInst = {} - } - } - Frame { anchors.centerIn: parent height: parent.height * 0.8 width: parent.width * 0.8 - Loader { - active: globalUtilsReady && mainModuleReady + ProfilePopupInviteMessagePanel { + id: panel anchors.fill: parent - sourceComponent: ProfilePopupInviteMessagePanel { - id: panel + contactsModel: ListModel { + Component.onCompleted: { + const keys = [] - contactsModel: ListModel { - Component.onCompleted: { - const keys = [] + for (let i = 0; i < 20; i++) { + const key = `pub_key_${i}` - for (let i = 0; i < 20; i++) { - const key = `pub_key_${i}` + append({ + isContact: true, + onlineStatus: 1, + displayName: `contact ${i}`, + icon: "", + colorId: "1", + pubKey: key, + compressedKey: "zx3sh" + key, + colorHash: [ + { colorId: i, segmentLength: i % 5 }, + { colorId: i + 5, segmentLength: 3 }, + { colorId: 19, segmentLength: 2 } + ] + }) - append({ - isContact: true, - onlineStatus: 1, - displayName: `contact ${i}`, - icon: "", - colorId: "1", - pubKey: key - }) - - keys.push(key) - } - - panel.pubKeys = keys + keys.push(key) } + + panel.pubKeys = keys } } } diff --git a/ui/app/mainui/Popups.qml b/ui/app/mainui/Popups.qml index adfb1b03f9..c2fe9e74f7 100644 --- a/ui/app/mainui/Popups.qml +++ b/ui/app/mainui/Popups.qml @@ -5,6 +5,7 @@ import QtQuick.Dialogs 1.3 import QtQml.Models 2.15 import QtQml 2.15 +import StatusQ 0.1 import StatusQ.Core 0.1 import StatusQ.Controls 0.1 import StatusQ.Components 0.1 @@ -32,6 +33,8 @@ import shared.status 1.0 import shared.stores 1.0 import shared.views 1.0 +import SortFilterProxyModel 0.2 + import utils 1.0 QtObject { @@ -440,7 +443,17 @@ QtObject { InviteFriendsToCommunityPopup { rootStore: root.rootStore - contactsModel: root.rootStore.contactStore.myContactsModel + + contactsModel: SortFilterProxyModel { + sourceModel: root.rootStore.contactStore.myContactsModel + + proxyRoles: FastExpressionRole { + name: "compressedKey" + expression: root.utilsStore.getCompressedPk(model.pubKey) + expectedRoles: ["pubKey"] + } + } + onClosed: destroy() } }, diff --git a/ui/imports/shared/stores/UtilsStore.qml b/ui/imports/shared/stores/UtilsStore.qml index 38b433da92..5e62c895a9 100644 --- a/ui/imports/shared/stores/UtilsStore.qml +++ b/ui/imports/shared/stores/UtilsStore.qml @@ -39,4 +39,13 @@ QtObject { function changeCommunityKeyCompression(communityKey) { return d.globalUtilsInst.changeCommunityKeyCompression(communityKey) } + + function getCompressedPk(publicKey) { + if (publicKey === "") { + return "" + } + if (!isChatKey(publicKey)) + return publicKey + return d.globalUtilsInst.getCompressedPk(publicKey) + } } diff --git a/ui/imports/shared/views/ExistingContacts.qml b/ui/imports/shared/views/ExistingContacts.qml index 38f7887e51..9afd97eff8 100644 --- a/ui/imports/shared/views/ExistingContacts.qml +++ b/ui/imports/shared/views/ExistingContacts.qml @@ -82,7 +82,7 @@ Item { delegate: StatusMemberListItem { width: contactListView.availableWidth - pubKey: model.isEnsVerified ? "" : Utils.getCompressedPk(model.pubKey) + pubKey: model.isEnsVerified ? "" : model.compressedKey isContact: model.isContact status: model.onlineStatus height: visible ? implicitHeight : 0 diff --git a/ui/imports/shared/views/PickedContacts.qml b/ui/imports/shared/views/PickedContacts.qml index 3307986458..65d585c4f6 100644 --- a/ui/imports/shared/views/PickedContacts.qml +++ b/ui/imports/shared/views/PickedContacts.qml @@ -35,7 +35,7 @@ Item { delegate: StatusMemberListItem { width: contactGridView.cellWidth - pubKey: model.isEnsVerified ? "" : Utils.getCompressedPk(model.pubKey) + pubKey: model.isEnsVerified ? "" : model.compressedKey isContact: model.isContact status: model.onlineStatus nickName: model.localNickname