[ActivityReminder] Actually commiting the fix to mustAlert

master
Stiralbios 2022-05-12 12:21:21 +02:00
parent 740b81e076
commit f46159ef8e
2 changed files with 13 additions and 4 deletions

View File

@ -10,6 +10,10 @@ function run() {
activityreminder_data.stepsOnDate = health.steps;
activityreminder_data.stepsDate = now;
activityreminder.saveData(activityreminder_data);
/* todo in a futur release
add settimer to trigger like 10 secs after the stepsDate + minSteps
cancel all other timers of this app
*/
}
if(activityreminder.mustAlert(activityreminder_data, activityreminder_settings)){
@ -20,7 +24,7 @@ function run() {
}
function isNotWorn() {
// todo check temperature and mouvement in a futur release
// todo in a futur release check temperature and mouvement in a futur release
return Bangle.isCharging();
}
@ -33,4 +37,9 @@ if (activityreminder_settings.enabled) {
activityreminder.saveData(activityreminder_data);
}
setInterval(run, 60000);
/* todo in a futur release
increase setInterval time to something that is still sensible (5 mins ?)
add settimer to trigger like 10 secs after the stepsDate + minSteps
cancel all other timers of this app
*/
}

View File

@ -47,9 +47,9 @@ exports.loadData = function () {
exports.mustAlert = function(activityreminder_data, activityreminder_settings) {
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
(now - activityreminder_settings.pauseDate) / 60000 > activityreminder_settings.pauseDelayMin) { // last alert was more than pauseDelayMin ago
if ((now - activityreminder_data.okDate) / 60000 > 3 && // last alert anwsered with ok was more than 3 min ago
(now - activityreminder_data.dismissDate) / 60000 > activityreminder_settings.dismissDelayMin && // last alert was more than dismissDelayMin ago
(now - activityreminder_data.pauseDate) / 60000 > activityreminder_settings.pauseDelayMin) { // last alert was more than pauseDelayMin ago
return true;
}
}