Skip to content

Commit

Permalink
fix-keep-panes-settings-after-reload
Browse files Browse the repository at this point in the history
  • Loading branch information
luis-411 committed Nov 3, 2024
1 parent 63db4c5 commit 04eb169
Showing 1 changed file with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ export class PaneController extends AbstractViewController implements InternalEv
currentItemsPanelWidth = 0
focusModeEnabled = false

listPaneExplicitelyCollapsed = false
navigationPaneExplicitelyCollapsed = false
listPaneExplicitelyCollapsed = localStorage.getItem("listPaneCollapsed")=="true"
navigationPaneExplicitelyCollapsed = localStorage.getItem("navPaneCollapsed")=="true"

constructor(
private preferences: PreferenceServiceInterface,
Expand Down Expand Up @@ -86,9 +86,17 @@ export class PaneController extends AbstractViewController implements InternalEv

const screen = this._isTabletOrMobileScreen.execute().getValue()

this.panes = screen.isTabletOrMobile
? [AppPaneId.Navigation, AppPaneId.Items]
: [AppPaneId.Navigation, AppPaneId.Items, AppPaneId.Editor]
if (screen.isTabletOrMobile) {
this.panes = [AppPaneId.Navigation, AppPaneId.Items]
} else {
if (!this.listPaneExplicitelyCollapsed && !this.navigationPaneExplicitelyCollapsed) {
this.panes = [AppPaneId.Navigation, AppPaneId.Items, AppPaneId.Editor]
} else if (this.listPaneExplicitelyCollapsed) {
this.panes = [AppPaneId.Navigation, AppPaneId.Editor]
} else {
this.panes = [AppPaneId.Items, AppPaneId.Editor]
}
}

const mediaQuery = window.matchMedia(MediaQueryBreakpoints.md)
if (mediaQuery?.addEventListener != undefined) {
Expand Down Expand Up @@ -251,23 +259,27 @@ export class PaneController extends AbstractViewController implements InternalEv
if (this.panes.includes(AppPaneId.Items)) {
this.removePane(AppPaneId.Items)
this.listPaneExplicitelyCollapsed = true
localStorage.setItem("listPaneCollapsed", "true")
} else {
if (this.panes.includes(AppPaneId.Navigation)) {
this.insertPaneAtIndex(AppPaneId.Items, 1)
} else {
this.insertPaneAtIndex(AppPaneId.Items, 0)
}
this.listPaneExplicitelyCollapsed = false
localStorage.setItem("listPaneCollapsed", "false")
}
}

toggleNavigationPane = () => {
if (this.panes.includes(AppPaneId.Navigation)) {
this.removePane(AppPaneId.Navigation)
this.navigationPaneExplicitelyCollapsed = true
localStorage.setItem("navPaneCollapsed", "true")
} else {
this.insertPaneAtIndex(AppPaneId.Navigation, 0)
this.navigationPaneExplicitelyCollapsed = false
localStorage.setItem("navPaneCollapsed", "false")
}
}

Expand Down

0 comments on commit 04eb169

Please sign in to comment.