perf(AppMain): wrap CommunitiesPortalLayout in a Loader

- CommunitiesPortalLayout was the last piece still unconditionally loaded
on startup -> fixed
- extract the `communitiesStore` into AppMain to be able to reuse it from
other components
- move the import/create community dialogs to `Popups` (reusability)
- cleanup and remove some dead code, fix warnings

Iterates #6204
This commit is contained in:
Lukáš Tinkl 2023-04-28 12:35:18 +02:00 committed by Lukáš Tinkl
parent 5615a534ea
commit e1c9f2f93f
11 changed files with 94 additions and 119 deletions

View File

@ -23,8 +23,6 @@ StackLayout {
property var emojiPopup
property var stickersPopup
signal importCommunityClicked()
signal createCommunityClicked()
signal profileButtonClicked()
signal openAppSearch()
@ -33,7 +31,6 @@ StackLayout {
}
Loader {
readonly property var chatItem: root.rootStore.chatCommunitySectionModule
sourceComponent: chatItem.isCommunity() && chatItem.requiresTokenPermissionToJoin && !chatItem.amIMember ? joinCommunityViewComponent : chatViewComponent
}
@ -116,12 +113,6 @@ StackLayout {
onCommunityInfoButtonClicked: root.currentIndex = 1
onCommunityManageButtonClicked: root.currentIndex = 1
onImportCommunityClicked: {
root.importCommunityClicked();
}
onCreateCommunityClicked: {
root.createCommunityClicked();
}
onProfileButtonClicked: {
root.profileButtonClicked()
}

View File

@ -38,8 +38,6 @@ StatusSectionLayout {
signal communityManageButtonClicked()
signal profileButtonClicked()
signal openAppSearch()
signal importCommunityClicked()
signal createCommunityClicked()
Connections {
target: root.rootStore.stickersStore.stickersModule
@ -139,12 +137,6 @@ StatusSectionLayout {
onOpenAppSearch: {
root.openAppSearch()
}
onImportCommunityClicked: {
root.importCommunityClicked();
}
onCreateCommunityClicked: {
root.createCommunityClicked();
}
onAddRemoveGroupMemberClicked: {
headerContent.addRemoveGroupMember()
}

View File

@ -32,12 +32,8 @@ Item {
property var contactsStore
property var emojiPopup
// Not Refactored Yet
//property int chatGroupsListViewCount: channelList.model.count
signal openProfileClicked()
signal openAppSearch()
signal importCommunityClicked()
signal createCommunityClicked()
signal addRemoveGroupMemberClicked()
// main layout

View File

@ -16,8 +16,6 @@ import shared.panels 1.0
import SortFilterProxyModel 0.2
import AppLayouts.CommunitiesPortal.stores 1.0
import "controls"
import "popups"
import "views"
@ -25,16 +23,12 @@ import "views"
StatusSectionLayout {
id: root
property CommunitiesStore communitiesStore: CommunitiesStore {}
property var importCommunitiesPopup: importCommunitiesPopupComponent
property var createCommunitiesPopup: createCommunitiesPopupComponent
property var discordImportProgressPopup: discordImportProgressDialog
property var communitiesStore
property alias assetsModel: communitiesGrid.assetsModel
property alias collectiblesModel: communitiesGrid.collectiblesModel
objectName: "communitiesPortalLayout"
notificationCount: activityCenterStore.unreadNotificationsCount
onNotificationButtonClicked: Global.openActivityCenterPopup()
onVisibleChanged: {
@ -133,7 +127,7 @@ StatusSectionLayout {
Layout.preferredHeight: 38
text: qsTr("Import using key")
verticalPadding: 0
onClicked: Global.openPopup(importCommunitiesPopupComponent)
onClicked: Global.importCommunityPopupRequested()
}
StatusButton {
@ -195,28 +189,6 @@ StatusSectionLayout {
}
}
Component {
id: importCommunitiesPopupComponent
ImportCommunityPopup {
anchors.centerIn: parent
store: root.communitiesStore
onClosed: {
destroy()
}
}
}
Component {
id: createCommunitiesPopupComponent
CreateCommunityPopup {
anchors.centerIn: parent
store: root.communitiesStore
onClosed: {
destroy()
}
}
}
Component {
id: chooseCommunityCreationTypePopupComponent
StatusDialog {
@ -236,7 +208,7 @@ StatusSectionLayout {
icon.name: "favourite"
onButtonClicked: {
chooseCommunityCreationTypePopup.close()
Global.openPopup(createCommunitiesPopupComponent)
Global.createCommunityPopupRequested(false /*isDiscordImport*/)
}
}
CommunityBanner {
@ -250,17 +222,10 @@ StatusSectionLayout {
buttonLoading: importInProgress
onButtonClicked: {
chooseCommunityCreationTypePopup.close()
Global.openPopup(createCommunitiesPopupComponent, {isDiscordImport: true})
Global.createCommunityPopupRequested(true /*isDiscordImport*/)
}
}
}
}
}
Component {
id: discordImportProgressDialog
DiscordImportProgressDialog {
store: root.communitiesStore
}
}
}

View File

@ -0,0 +1,2 @@
CreateCommunityPopup 1.0 CreateCommunityPopup.qml
DiscordImportProgressDialog 1.0 DiscordImportProgressDialog.qml

View File

@ -133,7 +133,7 @@ SettingsContentBase {
}
// TODO: replace with StatusQ component
StatusSettingsLineButton {
StatusSettingsLineButton {
anchors.leftMargin: 0
anchors.rightMargin: 0
text: qsTr("WakuV2 Store")
@ -515,27 +515,5 @@ SettingsContentBase {
close()
}
}
Component {
id: errorMessageDialogCmp
StatusDialog {
id: errorMessageDialog
property string errorMessage: ""
title: qsTr("An error occoured")
StatusBaseText {
anchors.fill: parent
text: {
if (errorMessageDialog.errorMessage.indexOf("address already in use") > -1) {
return qsTr("The specified torrent client port is already in use.")
}
return errorMessageDialog.errorMessage
}
}
standardButtons: Dialog.Ok
onAccepted: errorMessageDialog.close()
}
}
}
}

View File

@ -67,6 +67,7 @@ Item {
width: root.width
backButtonName: RootStore.backButtonName
notificationCount: activityCenterStore.unreadNotificationsCount
hasUnseenNotifications: activityCenterStore.hasUnseenNotifications
onNotificationButtonClicked: Global.openActivityCenterPopup()
onBackButtonClicked: {

View File

@ -198,7 +198,7 @@ Rectangle {
width: parent.width
font.weight: Font.Medium
font.pixelSize: 22
loading: RootStore.currentAccount.assetsLoading
loading: RootStore.assetsLoading
visible: !networkConnectionStore.accountBalanceNotAvailable
}

View File

@ -34,6 +34,7 @@ import StatusQ.Core 0.1
import AppLayouts.Browser.stores 1.0 as BrowserStores
import AppLayouts.stores 1.0
import AppLayouts.Chat.stores 1.0 as ChatStores
import AppLayouts.CommunitiesPortal.stores 1.0
import mainui.activitycenter.stores 1.0
import mainui.activitycenter.popups 1.0
@ -57,6 +58,7 @@ Item {
property ActivityCenterStore activityCenterStore: ActivityCenterStore {}
property NetworkConnectionStore networkConnectionStore: NetworkConnectionStore {}
property CommunityTokensStore communityTokensStore: CommunityTokensStore {}
property CommunitiesStore communitiesStore: CommunitiesStore {}
// set from main.qml
property var sysPalette
@ -114,6 +116,7 @@ Item {
id: popups
popupParent: appMain
rootStore: appMain.rootStore
communitiesStore: appMain.communitiesStore
}
Connections {
@ -192,7 +195,7 @@ Item {
}
function onSwitchToCommunity(communityId: string) {
communitiesPortalLayoutContainer.communitiesStore.setActiveCommunity(communityId)
appMain.communitiesStore.setActiveCommunity(communityId)
}
}
@ -242,10 +245,13 @@ Item {
}
}
StatusEmojiPopup {
Loader {
id: statusEmojiPopup
width: 360
height: 440
active: appMain.rootStore.mainModuleInst.sectionsLoaded
sourceComponent: StatusEmojiPopup {
width: 360
height: 440
}
}
Loader {
@ -558,15 +564,15 @@ Item {
ModuleWarning {
Layout.fillWidth: true
readonly property int progress: communitiesPortalLayoutContainer.communitiesStore.discordImportProgress
readonly property bool inProgress: (progress > 0 && progress < 100) || communitiesPortalLayoutContainer.communitiesStore.discordImportInProgress
readonly property int progress: appMain.communitiesStore.discordImportProgress
readonly property bool inProgress: (progress > 0 && progress < 100) || appMain.communitiesStore.discordImportInProgress
readonly property bool finished: progress >= 100
readonly property bool cancelled: communitiesPortalLayoutContainer.communitiesStore.discordImportCancelled
readonly property bool stopped: communitiesPortalLayoutContainer.communitiesStore.discordImportProgressStopped
readonly property int errors: communitiesPortalLayoutContainer.communitiesStore.discordImportErrorsCount
readonly property int warnings: communitiesPortalLayoutContainer.communitiesStore.discordImportWarningsCount
readonly property string communityId: communitiesPortalLayoutContainer.communitiesStore.discordImportCommunityId
readonly property string communityName: communitiesPortalLayoutContainer.communitiesStore.discordImportCommunityName
readonly property bool cancelled: appMain.communitiesStore.discordImportCancelled
readonly property bool stopped: appMain.communitiesStore.discordImportProgressStopped
readonly property int errors: appMain.communitiesStore.discordImportErrorsCount
readonly property int warnings: appMain.communitiesStore.discordImportWarningsCount
readonly property string communityId: appMain.communitiesStore.discordImportCommunityId
readonly property string communityName: appMain.communitiesStore.discordImportCommunityName
active: !cancelled && (inProgress || finished || stopped)
type: errors ? ModuleWarning.Type.Danger : ModuleWarning.Type.Success
@ -595,12 +601,12 @@ Item {
return ""
}
onLinkActivated: popups.openPopup(communitiesPortalLayoutContainer.discordImportProgressPopup)
onLinkActivated: popups.openDiscordImportProgressPopup()
progressValue: progress
closeBtnVisible: finished || stopped
buttonText: finished && !errors ? qsTr("Visit your Community") : ""
onClicked: function() {
communitiesPortalLayoutContainer.communitiesStore.setActiveCommunity(communityId)
appMain.communitiesStore.setActiveCommunity(communityId)
}
onCloseClicked: {
hide();
@ -610,7 +616,7 @@ Item {
ModuleWarning {
id: downloadingArchivesBanner
Layout.fillWidth: true
active: communitiesPortalLayoutContainer.communitiesStore.downloadingCommunityHistoryArchives
active: appMain.communitiesStore.downloadingCommunityHistoryArchives
type: ModuleWarning.Danger
text: qsTr("Downloading message history archives, DO NOT CLOSE THE APP until this banner disappears.")
closeBtnVisible: false
@ -881,7 +887,7 @@ Item {
StatusBaseText {
text: qsTr("Loading sections...")
}
LoadingAnimation {}
LoadingAnimation { anchors.verticalCenter: parent.verticalCenter }
}
}
}
@ -919,7 +925,7 @@ Item {
chatCommunitySectionModule: appMain.rootStore.mainModuleInst.getChatSectionModule()
networkConnectionStore: appMain.networkConnectionStore
}
emojiPopup: statusEmojiPopup
emojiPopup: statusEmojiPopup.item
stickersPopup: statusStickersPopupLoader.item
onProfileButtonClicked: {
@ -929,23 +935,21 @@ Item {
onOpenAppSearch: {
appSearch.openSearchPopup()
}
onImportCommunityClicked: {
popups.openPopup(communitiesPortalLayoutContainer.importCommunitiesPopup);
}
onCreateCommunityClicked: {
popups.openPopup(communitiesPortalLayoutContainer.createCommunitiesPopup);
}
}
}
}
CommunitiesPortalLayout {
id: communitiesPortalLayoutContainer
assetsModel: rootChatStore.assetsModel
collectiblesModel: rootChatStore.collectiblesModel
Loader {
active: appView.currentIndex === Constants.appViewStackIndex.communitiesPortal
asynchronous: true
CommunitiesPortalLayout {
anchors.fill: parent
communitiesStore: appMain.communitiesStore
assetsModel: appMain.rootChatStore.assetsModel
collectiblesModel: appMain.rootChatStore.collectiblesModel
notificationCount: appMain.activityCenterStore.unreadNotificationsCount
hasUnseenNotifications: activityCenterStore.hasUnseenNotifications
}
}
Loader {
@ -954,7 +958,7 @@ Item {
sourceComponent: WalletLayout {
store: appMain.rootStore
contactsStore: appMain.rootStore.profileSectionStore.contactsStore
emojiPopup: statusEmojiPopup
emojiPopup: statusEmojiPopup.item
sendModalPopup: sendModal
networkConnectionStore: appMain.networkConnectionStore
}
@ -987,7 +991,7 @@ Item {
store: appMain.rootStore.profileSectionStore
globalStore: appMain.rootStore
systemPalette: appMain.sysPalette
emojiPopup: statusEmojiPopup
emojiPopup: statusEmojiPopup.item
networkConnectionStore: appMain.networkConnectionStore
}
}
@ -1039,7 +1043,7 @@ Item {
restoreMode: Binding.RestoreBindingOrValue
}
emojiPopup: statusEmojiPopup
emojiPopup: statusEmojiPopup.item
stickersPopup: statusStickersPopupLoader.item
sectionItemModel: model
@ -1090,7 +1094,7 @@ Item {
openCreateChat: createChatView.opened
chatCommunitySectionModule: appMain.rootStore.mainModuleInst.getChatSectionModule()
}
emojiPopup: statusEmojiPopup
emojiPopup: statusEmojiPopup.item
stickersPopup: statusStickersPopupLoader.item
}
}
@ -1322,7 +1326,7 @@ Item {
settings = {}
}
// Set Status links as true. We intercept thoseURLs so it is privacy-safe
// Set Status links as true. We intercept those URLs so it is privacy-safe
if (!settings[Constants.deepLinkPrefix] || !settings[Constants.joinStatusLink]) {
settings[Constants.deepLinkPrefix] = true
settings[Constants.joinStatusLink] = true

View File

@ -2,6 +2,7 @@ import QtQuick 2.15
import AppLayouts.Chat.popups 1.0
import AppLayouts.Profile.popups 1.0
import AppLayouts.CommunitiesPortal.popups 1.0
import shared.popups 1.0
import shared.status 1.0
@ -13,6 +14,7 @@ QtObject {
required property var popupParent
required property var rootStore
property var communitiesStore
property var activePopupComponents: []
@ -34,6 +36,8 @@ QtObject {
Global.openEditDisplayNamePopup.connect(openEditDisplayNamePopup)
Global.openPinnedMessagesPopupRequested.connect(openPinnedMessagesPopup)
Global.openCommunityProfilePopupRequested.connect(openCommunityProfilePopup)
Global.createCommunityPopupRequested.connect(openCreateCommunityPopup)
Global.importCommunityPopupRequested.connect(openImportCommunityPopup)
Global.openPopupRequested.connect(openPopup)
}
@ -182,6 +186,18 @@ QtObject {
openPopup(communityProfilePopup, {store: store, community: community, chatCommunitySectionModule: chatCommunitySectionModule})
}
function openCreateCommunityPopup(isDiscordImport) {
openPopup(createCommunitiesPopupComponent, {isDiscordImport: isDiscordImport})
}
function openImportCommunityPopup() {
openPopup(importCommunitiesPopupComponent)
}
function openDiscordImportProgressPopup() {
openPopup(discordImportProgressDialog)
}
readonly property list<Component> _components: [
Component {
id: contactVerificationRequestPopupComponent
@ -390,6 +406,34 @@ QtObject {
}
onClosed: destroy()
}
},
Component {
id: importCommunitiesPopupComponent
ImportCommunityPopup {
store: root.communitiesStore
onClosed: {
destroy()
}
}
},
Component {
id: createCommunitiesPopupComponent
CreateCommunityPopup {
anchors.centerIn: parent
store: root.communitiesStore
onClosed: {
destroy()
}
}
},
Component {
id: discordImportProgressDialog
DiscordImportProgressDialog {
store: root.communitiesStore
}
}
]
}

View File

@ -50,6 +50,8 @@ QtObject {
signal openSendModal(string address)
signal switchToCommunity(string communityId)
signal createCommunityPopupRequested(bool isDiscordImport)
signal importCommunityPopupRequested()
signal playSendMessageSound()
signal playNotificationSound()