From 143cf63dc04f3c1905774c6948f06b121e94a970 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Cie=C5=9Blak?= Date: Mon, 28 Oct 2024 11:40:58 +0100 Subject: [PATCH] Community invite flow: dependency on stores reduced --- .../InviteFriendsToCommunityPopupPage.qml | 32 ++++++++--------- .../ProfilePopupInviteMessagePanelPage.qml | 34 +++++++++---------- .../panels/ProfilePopupInviteFriendsPanel.qml | 7 ++-- .../panels/ProfilePopupInviteMessagePanel.qml | 8 ++--- .../popups/InviteFriendsToCommunityPopup.qml | 9 +++-- ui/app/mainui/Popups.qml | 2 +- ui/imports/shared/views/ExistingContacts.qml | 6 ++-- ui/imports/shared/views/PickedContacts.qml | 16 ++++----- 8 files changed, 54 insertions(+), 60 deletions(-) diff --git a/storybook/pages/InviteFriendsToCommunityPopupPage.qml b/storybook/pages/InviteFriendsToCommunityPopupPage.qml index c2dc5c5c30..b69e342dd6 100644 --- a/storybook/pages/InviteFriendsToCommunityPopupPage.qml +++ b/storybook/pages/InviteFriendsToCommunityPopupPage.qml @@ -118,24 +118,22 @@ SplitView { } } - contactsStore: ProfileStores.ContactsStore { - readonly property ListModel myContactsModel: ListModel { - Component.onCompleted: { - for (let i = 0; i < 20; i++) { - const key = `pub_key_${i}` + contactsModel: ListModel { + Component.onCompleted: { + 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 + }) } } } diff --git a/storybook/pages/ProfilePopupInviteMessagePanelPage.qml b/storybook/pages/ProfilePopupInviteMessagePanelPage.qml index cb9a527168..8ced8173ce 100644 --- a/storybook/pages/ProfilePopupInviteMessagePanelPage.qml +++ b/storybook/pages/ProfilePopupInviteMessagePanelPage.qml @@ -65,28 +65,26 @@ Item { sourceComponent: ProfilePopupInviteMessagePanel { id: panel - 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({ - isContact: true, - onlineStatus: 1, - displayName: `contact ${i}`, - icon: "", - colorId: "1", - pubKey: key - }) + 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/AppLayouts/Communities/panels/ProfilePopupInviteFriendsPanel.qml b/ui/app/AppLayouts/Communities/panels/ProfilePopupInviteFriendsPanel.qml index cd585f5259..bc79311cb0 100644 --- a/ui/app/AppLayouts/Communities/panels/ProfilePopupInviteFriendsPanel.qml +++ b/ui/app/AppLayouts/Communities/panels/ProfilePopupInviteFriendsPanel.qml @@ -15,7 +15,6 @@ import shared.views 1.0 import shared.status 1.0 import AppLayouts.stores 1.0 as AppLayoutStores -import AppLayouts.Profile.stores 1.0 as ProfileStores ColumnLayout { id: root @@ -24,7 +23,8 @@ ColumnLayout { property string headerTitle: "" property AppLayoutStores.RootStore rootStore - property ProfileStores.ContactsStore contactsStore + + property var contactsModel property string communityId property var pubKeys: ([]) @@ -57,7 +57,8 @@ ColumnLayout { id: existingContacts rootStore: root.rootStore - contactsStore: root.contactsStore + + contactsModel: root.contactsModel communityId: root.communityId hideCommunityMembers: true diff --git a/ui/app/AppLayouts/Communities/panels/ProfilePopupInviteMessagePanel.qml b/ui/app/AppLayouts/Communities/panels/ProfilePopupInviteMessagePanel.qml index 04cfbb8ef3..d12ae601cc 100644 --- a/ui/app/AppLayouts/Communities/panels/ProfilePopupInviteMessagePanel.qml +++ b/ui/app/AppLayouts/Communities/panels/ProfilePopupInviteMessagePanel.qml @@ -13,16 +13,13 @@ import shared.panels 1.0 import shared.views 1.0 import shared.status 1.0 -import AppLayouts.Profile.stores 1.0 as ProfileStores - ColumnLayout { id: root objectName: "CommunityProfilePopupInviteMessagePanel_ColumnLayout" + property var contactsModel property var pubKeys: ([]) - property ProfileStores.ContactsStore contactsStore - property alias inviteMessage: messageInput.text spacing: Theme.padding @@ -62,7 +59,8 @@ ColumnLayout { PickedContacts { id: existingContacts - contactsStore: root.contactsStore + + contactsModel: root.contactsModel pubKeys: root.pubKeys Layout.fillWidth: true Layout.fillHeight: true diff --git a/ui/app/AppLayouts/Communities/popups/InviteFriendsToCommunityPopup.qml b/ui/app/AppLayouts/Communities/popups/InviteFriendsToCommunityPopup.qml index 9304811106..f7e1048168 100644 --- a/ui/app/AppLayouts/Communities/popups/InviteFriendsToCommunityPopup.qml +++ b/ui/app/AppLayouts/Communities/popups/InviteFriendsToCommunityPopup.qml @@ -17,7 +17,8 @@ StatusStackModal { id: root property AppLayoutStores.RootStore rootStore - property ProfileStores.ContactsStore contactsStore + + property var contactsModel property var community property var communitySectionModule @@ -95,13 +96,15 @@ StatusStackModal { stackItems: [ ProfilePopupInviteFriendsPanel { rootStore: root.rootStore - contactsStore: root.contactsStore + + contactsModel: root.contactsModel communityId: root.community.id + onPubKeysChanged: root.pubKeys = pubKeys }, ProfilePopupInviteMessagePanel { - contactsStore: root.contactsStore + contactsModel: root.contactsModel pubKeys: root.pubKeys onInviteMessageChanged: root.inviteMessage = inviteMessage } diff --git a/ui/app/mainui/Popups.qml b/ui/app/mainui/Popups.qml index 30dc618359..adfb1b03f9 100644 --- a/ui/app/mainui/Popups.qml +++ b/ui/app/mainui/Popups.qml @@ -440,7 +440,7 @@ QtObject { InviteFriendsToCommunityPopup { rootStore: root.rootStore - contactsStore: root.rootStore.contactStore + contactsModel: root.rootStore.contactStore.myContactsModel onClosed: destroy() } }, diff --git a/ui/imports/shared/views/ExistingContacts.qml b/ui/imports/shared/views/ExistingContacts.qml index 44df9068c9..38f7887e51 100644 --- a/ui/imports/shared/views/ExistingContacts.qml +++ b/ui/imports/shared/views/ExistingContacts.qml @@ -13,7 +13,6 @@ import shared.stores 1.0 // TODO move Contact into shared to get rid of that import import AppLayouts.Chat.controls 1.0 import AppLayouts.stores 1.0 as AppLayoutStores -import AppLayouts.Profile.stores 1.0 as ProfileStores import SortFilterProxyModel 0.2 @@ -21,7 +20,8 @@ Item { id: root property AppLayoutStores.RootStore rootStore - property ProfileStores.ContactsStore contactsStore + + property var contactsModel property string communityId property string filterText: "" @@ -51,7 +51,7 @@ Item { spacing: Theme.padding model: SortFilterProxyModel { - sourceModel: root.contactsStore.myContactsModel + sourceModel: root.contactsModel filters: [ ExpressionFilter { expression: { diff --git a/ui/imports/shared/views/PickedContacts.qml b/ui/imports/shared/views/PickedContacts.qml index b34f3af7e6..3307986458 100644 --- a/ui/imports/shared/views/PickedContacts.qml +++ b/ui/imports/shared/views/PickedContacts.qml @@ -7,15 +7,13 @@ import StatusQ.Components 0.1 import StatusQ.Core.Theme 0.1 import utils 1.0 -import AppLayouts.Profile.stores 1.0 as ProfileStores import SortFilterProxyModel 0.2 Item { id: root - property ProfileStores.ContactsStore contactsStore - + property var contactsModel property var pubKeys: ([]) readonly property alias count: contactGridView.count @@ -28,13 +26,11 @@ Item { cellHeight: 2 * Theme.xlPadding + Theme.halfPadding model: SortFilterProxyModel { - sourceModel: root.contactsStore.myContactsModel - filters: [ - FastExpressionFilter { - expression: root.pubKeys.indexOf(model.pubKey) > -1 - expectedRoles: ["pubKey"] - } - ] + sourceModel: root.contactsModel + filters: FastExpressionFilter { + expression: root.pubKeys.indexOf(model.pubKey) > -1 + expectedRoles: ["pubKey"] + } } delegate: StatusMemberListItem {