@@ -2,6 +2,8 @@ import { PanesForLayout } from './../../Application/UseCase/PanesForLayout'
2
2
import {
3
3
InternalEventHandlerInterface ,
4
4
InternalEventInterface ,
5
+ LocalPrefDefaults ,
6
+ LocalPrefKey ,
5
7
PreferenceServiceInterface ,
6
8
} from '@standardnotes/services'
7
9
import {
@@ -42,8 +44,8 @@ export class PaneController extends AbstractViewController implements InternalEv
42
44
currentItemsPanelWidth = 0
43
45
focusModeEnabled = false
44
46
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 ] )
47
49
48
50
constructor (
49
51
private preferences : PreferenceServiceInterface ,
@@ -106,6 +108,7 @@ export class PaneController extends AbstractViewController implements InternalEv
106
108
}
107
109
108
110
eventBus . addEventHandler ( this , ApplicationEvent . PreferencesChanged )
111
+ eventBus . addEventHandler ( this , ApplicationEvent . LocalPreferencesChanged )
109
112
110
113
this . disposers . push (
111
114
keyboardService . addCommandHandler ( {
@@ -144,6 +147,10 @@ export class PaneController extends AbstractViewController implements InternalEv
144
147
this . setCurrentNavPanelWidth ( this . preferences . getValue ( PrefKey . TagsPanelWidth , MinimumNavPanelWidth ) )
145
148
this . setCurrentItemsPanelWidth ( this . preferences . getValue ( PrefKey . NotesPanelWidth , MinimumNotesPanelWidth ) )
146
149
}
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
+ }
147
154
}
148
155
149
156
setCurrentNavPanelWidth ( width : number ) {
@@ -258,28 +265,24 @@ export class PaneController extends AbstractViewController implements InternalEv
258
265
toggleListPane = ( ) => {
259
266
if ( this . panes . includes ( AppPaneId . Items ) ) {
260
267
this . removePane ( AppPaneId . Items )
261
- this . listPaneExplicitelyCollapsed = true
262
- localStorage . setItem ( "listPaneCollapsed" , "true" )
268
+ this . preferences . setLocalValue ( LocalPrefKey . ListPaneCollapsed , true )
263
269
} else {
264
270
if ( this . panes . includes ( AppPaneId . Navigation ) ) {
265
271
this . insertPaneAtIndex ( AppPaneId . Items , 1 )
266
272
} else {
267
273
this . insertPaneAtIndex ( AppPaneId . Items , 0 )
268
274
}
269
- this . listPaneExplicitelyCollapsed = false
270
- localStorage . setItem ( "listPaneCollapsed" , "false" )
275
+ this . preferences . setLocalValue ( LocalPrefKey . ListPaneCollapsed , false )
271
276
}
272
277
}
273
278
274
279
toggleNavigationPane = ( ) => {
275
280
if ( this . panes . includes ( AppPaneId . Navigation ) ) {
276
281
this . removePane ( AppPaneId . Navigation )
277
- this . navigationPaneExplicitelyCollapsed = true
278
- localStorage . setItem ( "navPaneCollapsed" , "true" )
282
+ this . preferences . setLocalValue ( LocalPrefKey . NavigationPaneCollapsed , true )
279
283
} else {
280
284
this . insertPaneAtIndex ( AppPaneId . Navigation , 0 )
281
- this . navigationPaneExplicitelyCollapsed = false
282
- localStorage . setItem ( "navPaneCollapsed" , "false" )
285
+ this . preferences . setLocalValue ( LocalPrefKey . NavigationPaneCollapsed , false )
283
286
}
284
287
}
285
288
0 commit comments