File tree Expand file tree Collapse file tree 1 file changed +10
-10
lines changed Expand file tree Collapse file tree 1 file changed +10
-10
lines changed Original file line number Diff line number Diff line change 11( function ( back ) {
22 var FILE = "BackLite.settings.json" ;
3- // Load settings
4- var settings = Object . assign ( {
5- brightness : 0.3 ,
6- } , require ( 'Storage' ) . readJSON ( FILE , true ) || { } ) ;
3+
4+ // Load settings safely (avoid crashes on bad/missing JSON)
5+ var settings = require ( "Storage" ) . readJSON ( FILE , 1 ) || { } ;
6+
7+ if ( ! isFinite ( settings . brightness ) ) settings . brightness = 0.3 ;
78
89 function writeSettings ( ) {
9- require ( ' Storage' ) . writeJSON ( FILE , settings ) ;
10+ require ( " Storage" ) . writeJSON ( FILE , settings ) ;
1011 }
1112
12- // Show the menu
1313 E . showMenu ( {
1414 "" : { "title" : "BackLite" } ,
15- "< Back" : back ,
16- ' Brightness' : {
17- value : settings . brightness || 0.3 ,
15+ "< Back" : ( ) => ( back ( ) ) , // fallback if run standalone
16+ " Brightness" : {
17+ value : settings . brightness ,
1818 min : 0.1 , max : 1 ,
1919 step : 0.1 ,
2020 onchange : v => {
2323 }
2424 } ,
2525 } ) ;
26- } )
26+ } ) ;
You can’t perform that action at this time.
0 commit comments