File tree Expand file tree Collapse file tree 3 files changed +11
-8
lines changed Expand file tree Collapse file tree 3 files changed +11
-8
lines changed Original file line number Diff line number Diff line change 3
3
* @param {string | string[] } key string or array of strings
4
4
* @returns {object }
5
5
*/
6
- export function get ( key ) {
6
+ export function get ( key , defaultValue = null ) {
7
7
let result = { } ;
8
8
if ( Array . isArray ( key ) ) {
9
9
key . forEach ( function ( element ) {
@@ -24,6 +24,12 @@ export function get(key) {
24
24
}
25
25
}
26
26
27
+ // if default value is set and key is not found in localStorage, set default value
28
+ if ( ! Object . keys ( result ) . length && defaultValue !== null ) {
29
+ console . log ( 'setting default value for' , key , defaultValue ) ;
30
+ result [ key ] = defaultValue ;
31
+ }
32
+
27
33
return result ;
28
34
}
29
35
Original file line number Diff line number Diff line change @@ -66,14 +66,15 @@ function readConfiguratorVersionMetadata() {
66
66
}
67
67
68
68
function cleanupLocalStorage ( ) {
69
-
69
+ // storage quota is 5MB, we need to clean up some stuff (more info see PR #2937)
70
70
const cleanupLocalStorageList = [
71
71
'cache' ,
72
72
'firmware' ,
73
73
'https' ,
74
74
'selected_board' ,
75
75
'unifiedConfigLast' ,
76
76
'unifiedSourceCache' ,
77
+ 'erase_chip' ,
77
78
] ;
78
79
79
80
for ( const key in localStorage ) {
Original file line number Diff line number Diff line change @@ -574,12 +574,8 @@ firmware_flasher.initialize = function (callback) {
574
574
self . isFlashing = false ;
575
575
}
576
576
577
- let result = getConfig ( 'erase_chip' ) ;
578
- if ( result . erase_chip ) {
579
- $ ( 'input.erase_chip' ) . prop ( 'checked' , true ) ;
580
- } else {
581
- $ ( 'input.erase_chip' ) . prop ( 'checked' , false ) ;
582
- }
577
+ let result = getConfig ( 'erase_chip' , true ) ;
578
+ $ ( 'input.erase_chip' ) . prop ( 'checked' , result . erase_chip ) ;
583
579
584
580
$ ( 'input.erase_chip' ) . change ( function ( ) {
585
581
setConfig ( { 'erase_chip' : $ ( this ) . is ( ':checked' ) } ) ;
You can’t perform that action at this time.
0 commit comments