File tree Expand file tree Collapse file tree 2 files changed +15
-8
lines changed Expand file tree Collapse file tree 2 files changed +15
-8
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,5 @@ export default class AppPreference extends Record({
8
8
showBookmarks : true ,
9
9
theme : THEMES . getDefault ( ) ,
10
10
} ) {
11
- merge ( map ) {
12
- return new AppPreference ( super . merge ( map ) ) ;
13
- }
11
+ static DEFAULT = new AppPreference ( )
14
12
}
Original file line number Diff line number Diff line change @@ -25,12 +25,21 @@ export default class AppPreferenceRepository {
25
25
}
26
26
}
27
27
28
+ /**
29
+ * @param {AppPreference } appPreference
30
+ */
28
31
save ( appPreference ) {
29
- const json = appPreference . toJS ( ) ;
30
- localStorage . setItem ( APP_PREFERENCE , JSON . stringify ( {
31
- ...json ,
32
- theme : json . theme . id ,
33
- } ) ) ;
32
+ const json = appPreference . toMap ( )
33
+ . filter ( ( value , key ) => value !== AppPreference . DEFAULT . get ( key ) )
34
+ . map ( ( value , key ) => {
35
+ switch ( key ) {
36
+ case 'theme' :
37
+ return value . id ;
38
+ default :
39
+ return value ;
40
+ }
41
+ } ) ;
42
+ localStorage . setItem ( APP_PREFERENCE , JSON . stringify ( json ) ) ;
34
43
35
44
// clean up old key
36
45
localStorage . removeItem ( HIDDEN_COMPONENTS ) ;
You can’t perform that action at this time.
0 commit comments