Fixed settings by adding check for null at the beginning

master
RKBoss6 2025-07-25 17:44:58 -04:00 committed by GitHub
parent 521aef8cc7
commit 63c7e5641a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 10 deletions

View File

@ -1,20 +1,20 @@
(function(back) {
var FILE = "BackLite.settings.json";
// Load settings
var settings = Object.assign({
brightness: 0.3,
}, require('Storage').readJSON(FILE, true) || {});
// Load settings safely (avoid crashes on bad/missing JSON)
var settings = require("Storage").readJSON(FILE, 1) || {};
if (!isFinite(settings.brightness)) settings.brightness = 0.3;
function writeSettings() {
require('Storage').writeJSON(FILE, settings);
require("Storage").writeJSON(FILE, settings);
}
// Show the menu
E.showMenu({
"" : { "title" : "BackLite" },
"< Back": back,
'Brightness': {
value: settings.brightness||0.3,
"< Back": () => (back()), // fallback if run standalone
"Brightness": {
value: settings.brightness,
min: 0.1, max: 1,
step: 0.1,
onchange: v => {
@ -23,4 +23,4 @@
}
},
});
})
});