Fix mustAlert, and, hopefully use let and const the JS way

master
Stiralbios 2022-05-12 11:34:42 +02:00
parent 689e6e7470
commit 740b81e076
4 changed files with 11 additions and 11 deletions

View File

@ -37,6 +37,6 @@ const storage = require("Storage");
g.clear();
Bangle.loadWidgets();
Bangle.drawWidgets();
activityreminder_settings = activityreminder.loadSettings();
activityreminder_data = activityreminder.loadData();
const activityreminder_settings = activityreminder.loadSettings();
const activityreminder_data = activityreminder.loadData();
run();

View File

@ -1,8 +1,8 @@
function run() {
if (isNotWorn()) return;
var now = new Date();
var h = now.getHours();
var health = Bangle.getHealthStatus("day");
let now = new Date();
let h = now.getHours();
let health = Bangle.getHealthStatus("day");
if (h >= activityreminder_settings.startHour && h < activityreminder_settings.endHour) {
if (health.steps - activityreminder_data.stepsOnDate >= activityreminder_settings.minSteps // more steps made than needed
@ -25,9 +25,9 @@ function isNotWorn() {
}
const activityreminder = require("activityreminder");
activityreminder_settings = activityreminder.loadSettings();
const activityreminder_settings = activityreminder.loadSettings();
if (activityreminder_settings.enabled) {
activityreminder_data = activityreminder.loadData();
const activityreminder_data = activityreminder.loadData();
if(activityreminder_data.firstLoad){
activityreminder_data.firstLoad =false;
activityreminder.saveData(activityreminder_data);

View File

@ -21,8 +21,8 @@ exports.saveData = function (data) {
};
exports.loadData = function () {
var health = Bangle.getHealthStatus("day");
var data = Object.assign({
let health = Bangle.getHealthStatus("day");
const data = Object.assign({
firstLoad: true,
stepsDate: new Date(),
stepsOnDate: health.steps,
@ -45,7 +45,7 @@ exports.loadData = function () {
};
exports.mustAlert = function(activityreminder_data, activityreminder_settings) {
var now = new Date();
let now = new Date();
if ((now - activityreminder_data.stepsDate) / 60000 > activityreminder_settings.maxInnactivityMin) { // inactivity detected
if ((now - activityreminder_settings.okDate) / 60000 > 3 && // last alert anwsered with ok was more than 3 min ago
(now - activityreminder_settings.dismissDate) / 60000 > activityreminder_settings.dismissDelayMin && // last alert was more than dismissDelayMin ago

View File

@ -1,7 +1,7 @@
(function (back) {
// Load settings
const activityreminder = require("activityreminder");
var settings = activityreminder.loadSettings();
const settings = activityreminder.loadSettings();
// Show the menu
E.showMenu({