fix(CommunitySettings): Load the community settings on demand and preserve the load state

This commit is contained in:
Alex Jbanca 2024-03-12 13:25:05 +02:00 committed by Alex Jbanca
parent 3b17134451
commit 7be70ff010
1 changed files with 14 additions and 10 deletions

View File

@ -75,6 +75,16 @@ StackLayout {
}
}
Connections {
target: root.rootStore
function onGoToMembershipRequestsPage() {
root.currentIndex = 1 // go to settings
if (communitySettingsLoader.item) {
communitySettingsLoader.item.goTo(Constants.CommunitySettingsSections.Members, Constants.CommunityMembershipSubSections.MembershipRequests)
}
}
}
Component {
id: joinCommunityViewComponent
JoinCommunityView {
@ -195,8 +205,10 @@ StackLayout {
Loader {
id: communitySettingsLoader
active: root.rootStore.chatCommunitySectionModule.isCommunity() && root.isPrivilegedUser
active: root.rootStore.chatCommunitySectionModule.isCommunity() &&
root.isPrivilegedUser &&
(root.currentIndex === 1 || !!communitySettingsLoader.item) // lazy load and preserve state after loading
asynchronous: false // It's false on purpose. We want to load the component synchronously
sourceComponent: CommunitySettingsView {
id: communitySettingsView
rootStore: root.rootStore
@ -214,14 +226,6 @@ StackLayout {
onBackToCommunityClicked: root.currentIndex = 0
onFinaliseOwnershipClicked: Global.openFinaliseOwnershipPopup(community.id)
Connections {
target: root.rootStore
function onGoToMembershipRequestsPage() {
root.currentIndex = 1 // go to settings
communitySettingsView.goTo(Constants.CommunitySettingsSections.Members, Constants.CommunityMembershipSubSections.MembershipRequests)
}
}
}
}