Moving stuff around to be sure to instanciate the variable before even referencing them in functions

pull/1951/head
Stiralbios 2022-06-12 19:51:46 +02:00
parent 85a52afbf5
commit 59ee5b1a78
2 changed files with 20 additions and 13 deletions

View File

@ -1,4 +1,10 @@
(function () {
const activityreminder = require("activityreminder");
const storage = require("Storage");
const activityreminder_settings = activityreminder.loadSettings();
const activityreminder_data = activityreminder.loadData();
function drawAlert() {
E.showPrompt("Inactivity detected", {
title: "Activity reminder",
@ -31,13 +37,10 @@
eval(storage.read("activityreminder.settings.js"))(() => load());
}
}
const activityreminder = require("activityreminder");
const storage = require("Storage");
g.clear();
Bangle.loadWidgets();
Bangle.drawWidgets();
const activityreminder_settings = activityreminder.loadSettings();
const activityreminder_data = activityreminder.loadData();
run();
})();

View File

@ -1,4 +1,15 @@
(function () {
const activityreminder = require("activityreminder");
const activityreminder_settings = activityreminder.loadSettings();
if (activityreminder_settings.enabled) {
const activityreminder_data = activityreminder.loadData();
if (activityreminder_data.firstLoad) {
activityreminder_data.firstLoad = false;
activityreminder.saveData(activityreminder_data);
}
}
function run() {
if (isNotWorn()) return;
let now = new Date();
@ -49,15 +60,8 @@
}
});
const activityreminder = require("activityreminder");
const activityreminder_settings = activityreminder.loadSettings();
if (activityreminder_settings.enabled) {
const activityreminder_data = activityreminder.loadData();
if (activityreminder_data.firstLoad) {
activityreminder_data.firstLoad = false;
activityreminder.saveData(activityreminder_data);
}
setInterval(run, 60000);
/* todo in a futur release
increase setInterval time to something that is still sensible (5 mins ?)