@@ -2,6 +2,8 @@ import { PanesForLayout } from './../../Application/UseCase/PanesForLayout'
22import {
33 InternalEventHandlerInterface ,
44 InternalEventInterface ,
5+ LocalPrefDefaults ,
6+ LocalPrefKey ,
57 PreferenceServiceInterface ,
68} from '@standardnotes/services'
79import {
@@ -42,8 +44,8 @@ export class PaneController extends AbstractViewController implements InternalEv
4244 currentItemsPanelWidth = 0
4345 focusModeEnabled = false
4446
45- listPaneExplicitelyCollapsed = localStorage . getItem ( "listPaneCollapsed" ) == "true"
46- navigationPaneExplicitelyCollapsed = localStorage . getItem ( "navPaneCollapsed" ) == "true"
47+ listPaneExplicitelyCollapsed = this . preferences . getLocalValue ( LocalPrefKey . ListPaneCollapsed , LocalPrefDefaults [ LocalPrefKey . ListPaneCollapsed ] )
48+ navigationPaneExplicitelyCollapsed = this . preferences . getLocalValue ( LocalPrefKey . NavigationPaneCollapsed , LocalPrefDefaults [ LocalPrefKey . NavigationPaneCollapsed ] )
4749
4850 constructor (
4951 private preferences : PreferenceServiceInterface ,
@@ -106,6 +108,7 @@ export class PaneController extends AbstractViewController implements InternalEv
106108 }
107109
108110 eventBus . addEventHandler ( this , ApplicationEvent . PreferencesChanged )
111+ eventBus . addEventHandler ( this , ApplicationEvent . LocalPreferencesChanged )
109112
110113 this . disposers . push (
111114 keyboardService . addCommandHandler ( {
@@ -144,6 +147,10 @@ export class PaneController extends AbstractViewController implements InternalEv
144147 this . setCurrentNavPanelWidth ( this . preferences . getValue ( PrefKey . TagsPanelWidth , MinimumNavPanelWidth ) )
145148 this . setCurrentItemsPanelWidth ( this . preferences . getValue ( PrefKey . NotesPanelWidth , MinimumNotesPanelWidth ) )
146149 }
150+ if ( event . type === ApplicationEvent . LocalPreferencesChanged ) {
151+ this . listPaneExplicitelyCollapsed = this . preferences . getLocalValue ( LocalPrefKey . ListPaneCollapsed , LocalPrefDefaults [ LocalPrefKey . ListPaneCollapsed ] )
152+ this . navigationPaneExplicitelyCollapsed = this . preferences . getLocalValue ( LocalPrefKey . NavigationPaneCollapsed , LocalPrefDefaults [ LocalPrefKey . NavigationPaneCollapsed ] )
153+ }
147154 }
148155
149156 setCurrentNavPanelWidth ( width : number ) {
@@ -258,28 +265,24 @@ export class PaneController extends AbstractViewController implements InternalEv
258265 toggleListPane = ( ) => {
259266 if ( this . panes . includes ( AppPaneId . Items ) ) {
260267 this . removePane ( AppPaneId . Items )
261- this . listPaneExplicitelyCollapsed = true
262- localStorage . setItem ( "listPaneCollapsed" , "true" )
268+ this . preferences . setLocalValue ( LocalPrefKey . ListPaneCollapsed , true )
263269 } else {
264270 if ( this . panes . includes ( AppPaneId . Navigation ) ) {
265271 this . insertPaneAtIndex ( AppPaneId . Items , 1 )
266272 } else {
267273 this . insertPaneAtIndex ( AppPaneId . Items , 0 )
268274 }
269- this . listPaneExplicitelyCollapsed = false
270- localStorage . setItem ( "listPaneCollapsed" , "false" )
275+ this . preferences . setLocalValue ( LocalPrefKey . ListPaneCollapsed , false )
271276 }
272277 }
273278
274279 toggleNavigationPane = ( ) => {
275280 if ( this . panes . includes ( AppPaneId . Navigation ) ) {
276281 this . removePane ( AppPaneId . Navigation )
277- this . navigationPaneExplicitelyCollapsed = true
278- localStorage . setItem ( "navPaneCollapsed" , "true" )
282+ this . preferences . setLocalValue ( LocalPrefKey . NavigationPaneCollapsed , true )
279283 } else {
280284 this . insertPaneAtIndex ( AppPaneId . Navigation , 0 )
281- this . navigationPaneExplicitelyCollapsed = false
282- localStorage . setItem ( "navPaneCollapsed" , "false" )
285+ this . preferences . setLocalValue ( LocalPrefKey . NavigationPaneCollapsed , false )
283286 }
284287 }
285288
0 commit comments