qmsched: use Bangle.CLOCK instead of __FILE__

pull/1290/head
Richard de Boer 2022-01-13 10:54:46 +01:00
parent fd1511d7c6
commit fbdc932bd2
No known key found for this signature in database
GPG Key ID: 8721727971871937
2 changed files with 4 additions and 10 deletions

View File

@ -99,7 +99,7 @@ function applyTheme() {
* Library uses this to make the app update itself
* @param {int} mode New Quite Mode
*/
function setAppMode(mode) {
function setAppQuietMode(mode) {
if (mode === current) return;
current = mode;
delete m.lastIdx; // force redraw

View File

@ -21,14 +21,8 @@ function switchTheme(mode) {
dark: false
};
require("Storage").writeJSON("setting.json", s);
if (typeof __FILE__ === 'string') { // undefined means it loaded the default clock
const info = require("Storage").readJSON(__FILE__.split(".")[0]+".info", 1);
if (info && info.type!=="clock") { // info can have no type (but then it isn't a clock)
return; // not a clock: wait for user to switch apps
}
}
// current app is a clock: reload it with new theme
load(global.__FILE__);
// reload clocks with new theme, otherwise just wait for user to switch apps
if (Bangle.CLOCK) load(global.__FILE__);
}
/**
* Apply LCD options and theme for given mode
@ -53,5 +47,5 @@ exports.setMode = function(mode) {
));
exports.applyOptions(mode);
if (typeof WIDGETS === "object" && "qmsched" in WIDGETS) WIDGETS["qmsched"].draw();
if (global.__FILE__ === "qmsched.app.js") setAppMode(mode);
if (global.setAppQuietMode) setAppQuietMode(mode); // current app knows how to update itself
};