Skip to content

Commit 63c7e56

Browse files
authored
Fixed settings by adding check for null at the beginning
1 parent 521aef8 commit 63c7e56

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

apps/backlite/settings.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
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 => {
@@ -23,4 +23,4 @@
2323
}
2424
},
2525
});
26-
})
26+
});

0 commit comments

Comments
 (0)