Fix mustAlert, and, hopefully use let and const the JS way
parent
689e6e7470
commit
740b81e076
|
|
@ -37,6 +37,6 @@ const storage = require("Storage");
|
||||||
g.clear();
|
g.clear();
|
||||||
Bangle.loadWidgets();
|
Bangle.loadWidgets();
|
||||||
Bangle.drawWidgets();
|
Bangle.drawWidgets();
|
||||||
activityreminder_settings = activityreminder.loadSettings();
|
const activityreminder_settings = activityreminder.loadSettings();
|
||||||
activityreminder_data = activityreminder.loadData();
|
const activityreminder_data = activityreminder.loadData();
|
||||||
run();
|
run();
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
function run() {
|
function run() {
|
||||||
if (isNotWorn()) return;
|
if (isNotWorn()) return;
|
||||||
var now = new Date();
|
let now = new Date();
|
||||||
var h = now.getHours();
|
let h = now.getHours();
|
||||||
var health = Bangle.getHealthStatus("day");
|
let health = Bangle.getHealthStatus("day");
|
||||||
|
|
||||||
if (h >= activityreminder_settings.startHour && h < activityreminder_settings.endHour) {
|
if (h >= activityreminder_settings.startHour && h < activityreminder_settings.endHour) {
|
||||||
if (health.steps - activityreminder_data.stepsOnDate >= activityreminder_settings.minSteps // more steps made than needed
|
if (health.steps - activityreminder_data.stepsOnDate >= activityreminder_settings.minSteps // more steps made than needed
|
||||||
|
|
@ -25,9 +25,9 @@ function isNotWorn() {
|
||||||
}
|
}
|
||||||
|
|
||||||
const activityreminder = require("activityreminder");
|
const activityreminder = require("activityreminder");
|
||||||
activityreminder_settings = activityreminder.loadSettings();
|
const activityreminder_settings = activityreminder.loadSettings();
|
||||||
if (activityreminder_settings.enabled) {
|
if (activityreminder_settings.enabled) {
|
||||||
activityreminder_data = activityreminder.loadData();
|
const activityreminder_data = activityreminder.loadData();
|
||||||
if(activityreminder_data.firstLoad){
|
if(activityreminder_data.firstLoad){
|
||||||
activityreminder_data.firstLoad =false;
|
activityreminder_data.firstLoad =false;
|
||||||
activityreminder.saveData(activityreminder_data);
|
activityreminder.saveData(activityreminder_data);
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,8 @@ exports.saveData = function (data) {
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.loadData = function () {
|
exports.loadData = function () {
|
||||||
var health = Bangle.getHealthStatus("day");
|
let health = Bangle.getHealthStatus("day");
|
||||||
var data = Object.assign({
|
const data = Object.assign({
|
||||||
firstLoad: true,
|
firstLoad: true,
|
||||||
stepsDate: new Date(),
|
stepsDate: new Date(),
|
||||||
stepsOnDate: health.steps,
|
stepsOnDate: health.steps,
|
||||||
|
|
@ -45,7 +45,7 @@ exports.loadData = function () {
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.mustAlert = function(activityreminder_data, activityreminder_settings) {
|
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_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
|
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
|
(now - activityreminder_settings.dismissDate) / 60000 > activityreminder_settings.dismissDelayMin && // last alert was more than dismissDelayMin ago
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
(function (back) {
|
(function (back) {
|
||||||
// Load settings
|
// Load settings
|
||||||
const activityreminder = require("activityreminder");
|
const activityreminder = require("activityreminder");
|
||||||
var settings = activityreminder.loadSettings();
|
const settings = activityreminder.loadSettings();
|
||||||
|
|
||||||
// Show the menu
|
// Show the menu
|
||||||
E.showMenu({
|
E.showMenu({
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue