boot - Store found clock if none is configured

master
Martin Boonk 2022-10-21 12:31:26 +02:00
parent 451b9dbb03
commit 7526b6ecda
1 changed files with 7 additions and 3 deletions

View File

@ -1,6 +1,6 @@
// This runs after a 'fresh' boot // This runs after a 'fresh' boot
var clockApp=(require("Storage").readJSON("setting.json",1)||{}).clock; var s = require("Storage").readJSON("setting.json",1)||{};
if (clockApp) clockApp = require("Storage").read(clockApp); var clockApp = require("Storage").read(s.clock);
if (!clockApp) { if (!clockApp) {
clockApp = require("Storage").list(/\.info$/) clockApp = require("Storage").list(/\.info$/)
.map(file => { .map(file => {
@ -11,9 +11,13 @@ if (!clockApp) {
}) })
.filter(x=>x) .filter(x=>x)
.sort((a, b) => a.sortorder - b.sortorder)[0]; .sort((a, b) => a.sortorder - b.sortorder)[0];
if (clockApp) if (clockApp){
clockApp = require("Storage").read(clockApp.src); clockApp = require("Storage").read(clockApp.src);
s.clock = clockApp.src;
require("Storage").writeJSON("setting.json", s);
}
} }
if (!clockApp) clockApp=`E.showMessage("No Clock Found");setWatch(()=>{Bangle.showLauncher();}, global.BTN2||BTN, {repeat:false,edge:"falling"});`; if (!clockApp) clockApp=`E.showMessage("No Clock Found");setWatch(()=>{Bangle.showLauncher();}, global.BTN2||BTN, {repeat:false,edge:"falling"});`;
eval(clockApp); eval(clockApp);
delete s;
delete clockApp; delete clockApp;