Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: keep panes settings after reload #2888

Merged
merged 8 commits into from
Nov 22, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
initialization changed
  • Loading branch information
luis-411 committed Nov 21, 2024
commit b6d6694fbdffe02095764b4f72f29a66c0a23fea
Original file line number Diff line number Diff line change
@@ -92,19 +92,6 @@ export class PaneController extends AbstractViewController implements InternalEv
this.setCurrentNavPanelWidth(preferences.getValue(PrefKey.TagsPanelWidth, MinimumNavPanelWidth))
this.setCurrentItemsPanelWidth(preferences.getValue(PrefKey.NotesPanelWidth, MinimumNotesPanelWidth))

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

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) {
@@ -162,6 +149,20 @@ export class PaneController extends AbstractViewController implements InternalEv
LocalPrefKey.NavigationPaneCollapsed,
LocalPrefDefaults[LocalPrefKey.NavigationPaneCollapsed],
)
const screen = this._isTabletOrMobileScreen.execute().getValue()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will now run after every setLocalValue call, no? i think it makes more sense to have a boolean in the class to make sure this only runs once since its supposed to be initialization logic.

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.navigationPaneExplicitelyCollapsed) {
this.panes = [AppPaneId.Editor]
} else if (this.listPaneExplicitelyCollapsed) {
this.panes = [AppPaneId.Navigation, AppPaneId.Editor]
} else {
this.panes = [AppPaneId.Items, AppPaneId.Editor]
}
}
}
}