Fix the const reassign bug (cutting edge firmware) and better indentation and scoping

master
Stiralbios 2022-06-12 17:50:43 +02:00
parent 0cc0a40356
commit 85a52afbf5
6 changed files with 191 additions and 189 deletions

View File

@ -4,3 +4,4 @@
0.04: Obey system quiet mode 0.04: Obey system quiet mode
0.05: Battery optimisation, add the pause option, bug fixes 0.05: Battery optimisation, add the pause option, bug fixes
0.06: Add a temperature threshold to detect (and not alert) if the BJS isn't worn. Better support for the peoples using the app at night 0.06: Add a temperature threshold to detect (and not alert) if the BJS isn't worn. Better support for the peoples using the app at night
0.07: Fix bug on the cutting edge firmware

View File

@ -1,3 +1,4 @@
(function () {
function drawAlert() { function drawAlert() {
E.showPrompt("Inactivity detected", { E.showPrompt("Inactivity detected", {
title: "Activity reminder", title: "Activity reminder",
@ -31,7 +32,6 @@ function run() {
} }
} }
const activityreminder = require("activityreminder"); const activityreminder = require("activityreminder");
const storage = require("Storage"); const storage = require("Storage");
g.clear(); g.clear();
@ -40,3 +40,4 @@ Bangle.drawWidgets();
const activityreminder_settings = activityreminder.loadSettings(); const activityreminder_settings = activityreminder.loadSettings();
const activityreminder_data = activityreminder.loadData(); const activityreminder_data = activityreminder.loadData();
run(); run();
})();

View File

@ -1,3 +1,4 @@
(function () {
function run() { function run() {
if (isNotWorn()) return; if (isNotWorn()) return;
let now = new Date(); let now = new Date();
@ -48,6 +49,7 @@ Bangle.on('midnight', function() {
} }
}); });
const activityreminder = require("activityreminder"); const activityreminder = require("activityreminder");
const activityreminder_settings = activityreminder.loadSettings(); const activityreminder_settings = activityreminder.loadSettings();
if (activityreminder_settings.enabled) { if (activityreminder_settings.enabled) {
@ -62,4 +64,4 @@ if (activityreminder_settings.enabled) {
when we added a settimer when we added a settimer
*/ */
} }
})();

View File

@ -1,5 +1,3 @@
const storage = require("Storage");
exports.loadSettings = function () { exports.loadSettings = function () {
return Object.assign({ return Object.assign({
enabled: true, enabled: true,
@ -10,15 +8,15 @@ exports.loadSettings = function () {
pauseDelayMin: 120, pauseDelayMin: 120,
minSteps: 50, minSteps: 50,
tempThreshold: 27 tempThreshold: 27
}, storage.readJSON("activityreminder.s.json", true) || {}); }, require("Storage").readJSON("activityreminder.s.json", true) || {});
}; };
exports.writeSettings = function (settings) { exports.writeSettings = function (settings) {
storage.writeJSON("activityreminder.s.json", settings); require("Storage").writeJSON("activityreminder.s.json", settings);
}; };
exports.saveData = function (data) { exports.saveData = function (data) {
storage.writeJSON("activityreminder.data.json", data); require("Storage").writeJSON("activityreminder.data.json", data);
}; };
exports.loadData = function () { exports.loadData = function () {
@ -31,7 +29,7 @@ exports.loadData = function () {
dismissDate: new Date(1970), dismissDate: new Date(1970),
pauseDate: new Date(1970), pauseDate: new Date(1970),
}, },
storage.readJSON("activityreminder.data.json") || {}); require("Storage").readJSON("activityreminder.data.json") || {});
if(typeof(data.stepsDate) == "string") if(typeof(data.stepsDate) == "string")
data.stepsDate = new Date(data.stepsDate); data.stepsDate = new Date(data.stepsDate);

View File

@ -3,7 +3,7 @@
"name": "Activity Reminder", "name": "Activity Reminder",
"shortName":"Activity Reminder", "shortName":"Activity Reminder",
"description": "A reminder to take short walks for the ones with a sedentary lifestyle", "description": "A reminder to take short walks for the ones with a sedentary lifestyle",
"version":"0.06", "version":"0.07",
"icon": "app.png", "icon": "app.png",
"type": "app", "type": "app",
"tags": "tool,activity", "tags": "tool,activity",