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