fix(CommunitySettings): Previous page navigations are broken in community settings sections

Added property `previousPageName` into `SettingsPageLayout`.
Added needed slots in `CommunitySettingsView` to get `previousPageName` property changes and display the correct string.
Renamed `updateState` method to `navigateBack` to have a better accurate name.

Fixes #8455
This commit is contained in:
Noelia 2022-12-07 17:14:36 +01:00 committed by Noelia
parent 668ea868c4
commit 5d318d0304
4 changed files with 18 additions and 12 deletions

View File

@ -22,6 +22,7 @@ Item {
property bool headerButtonVisible: false
property string headerButtonText: ""
property int headerWidth: 0
property string previousPageName: ""
readonly property Item contentItem: contentLoader.item
readonly property size settingsDirtyToastMessageImplicitSize:

View File

@ -30,11 +30,12 @@ StackLayout {
property bool requestToJoinEnabled
property bool pinMessagesEnabled
property bool encrypted
property string previousPageName: (currentIndex === 1) ? qsTr("Overview") : ""
property bool editable: false
property bool owned: false
function updateState() {
function navigateBack() {
if (editCommunityPage.dirty) {
editCommunityPage.notifyDirty();
} else {

View File

@ -10,10 +10,12 @@ SettingsPageLayout {
property var store: CommunitiesStore {}
property int viewWidth: 560 // by design
property string previousPageName
function updateState() {
function navigateBack() {
if (root.state === d.newPermissionViewState) {
root.state = d.welcomeViewState;
root.state = d.getInitialState()
}
else if(root.state === d.permissionsViewState) {
root.state = d.newPermissionViewState;
}
}
@ -23,9 +25,13 @@ SettingsPageLayout {
readonly property string welcomeViewState: "WELCOME"
readonly property string newPermissionViewState: "NEWPERMISSION"
readonly property string permissionsViewState: "PERMISSIONS"
function getInitialState() {
return root.store.permissionsModel.count > 0 ? d.permissionsViewState : d.welcomeViewState
}
}
state: root.store.permissionsModel.count > 0 ? d.permissionsViewState : d.welcomeViewState
state: d.getInitialState()
states: [
State {
name: d.welcomeViewState

View File

@ -57,7 +57,7 @@ StatusSectionLayout {
signal openLegacyPopupClicked // TODO: remove me when migration to new settings is done
onBackButtonClicked: {
centerPanelContentLoader.item.children[d.currentIndex].updateState();
centerPanelContentLoader.item.children[d.currentIndex].navigateBack()
}
leftPanel: Item {
@ -178,9 +178,6 @@ StatusSectionLayout {
encrypted: root.community.encrypted
requestToJoinEnabled: root.community.access === Constants.communityChatOnRequestAccess
pinMessagesEnabled: root.community.pinMessageAllMembersEnabled
onCurrentIndexChanged: {
root.backButtonName = (currentIndex === 1) ? qsTr("Overview") : "";
}
editable: root.community.amISectionAdmin
onEdited: {
@ -215,6 +212,7 @@ StatusSectionLayout {
privateKey: root.chatCommunitySectionModule.exportCommunity(root.communityId),
})
}
onPreviousPageNameChanged: root.backButtonName = previousPageName
}
CommunityMembersSettingsPanel {
@ -234,10 +232,10 @@ StatusSectionLayout {
}
CommunityPermissionsSettingsPanel {
onStateChanged: {
root.backButtonName = previousPageName;
}
onPreviousPageNameChanged: root.backButtonName = previousPageName
}
onCurrentIndexChanged: root.backButtonName = centerPanelContentLoader.item.children[d.currentIndex].previousPageName
}
}