[sleeplogalarm] Correct filter for last alarm
parent
7ef5152c17
commit
ad7161cc93
|
|
@ -1,2 +1,3 @@
|
||||||
0.01: New App!
|
0.01: New App!
|
||||||
0.02: Add "from Consec."-setting
|
0.02: Add "from Consec."-setting
|
||||||
|
0.03: Correct how to ignore last triggered alarm
|
||||||
|
|
@ -8,13 +8,13 @@ function getNextAlarm(allAlarms, fo, withId) {
|
||||||
return a;
|
return a;
|
||||||
});
|
});
|
||||||
// return next active alarms in range, filter for
|
// return next active alarms in range, filter for
|
||||||
// active, not timer, not own alarm,
|
// active && not timer && not own alarm &&
|
||||||
// after from, before to, includes msg
|
// after from && before to && includes msg &&
|
||||||
// not lastTime, not lastDay
|
// lastDate not today || after lastTime
|
||||||
return allAlarms.filter(
|
return allAlarms.filter(
|
||||||
a => a.on && !a.timer && a.id !== "sleeplog" &&
|
a => a.on && !a.timer && a.id !== "sleeplog" &&
|
||||||
a.t >= fo.from && a.t < fo.to && (!fo.msg || a.msg.includes(fo.msg)) &&
|
a.t >= fo.from && a.t < fo.to && (!fo.msg || a.msg.includes(fo.msg)) &&
|
||||||
fo.lastTime !== a.t && fo.lastDay !== a.last
|
fo.lastDate !== new Date().getDate() || a.t > fo.lastTime
|
||||||
).map(a => { // add time to alarm
|
).map(a => { // add time to alarm
|
||||||
a.tTo = sched.getTimeToAlarm(a);
|
a.tTo = sched.getTimeToAlarm(a);
|
||||||
return a;
|
return a;
|
||||||
|
|
@ -58,7 +58,7 @@ exports = {
|
||||||
to: settings.filter_to * 36E5,
|
to: settings.filter_to * 36E5,
|
||||||
msg: settings.filter_msg,
|
msg: settings.filter_msg,
|
||||||
lastTime: settings.lastTime,
|
lastTime: settings.lastTime,
|
||||||
lastDay: settings.lastDay
|
lastDate: settings.lastDate
|
||||||
}).t;
|
}).t;
|
||||||
|
|
||||||
// abort if no alarm time could be found inside range
|
// abort if no alarm time could be found inside range
|
||||||
|
|
@ -95,7 +95,7 @@ exports = {
|
||||||
to: settings.filter_to * 36E5,
|
to: settings.filter_to * 36E5,
|
||||||
msg: settings.filter_msg,
|
msg: settings.filter_msg,
|
||||||
lastTime: settings.lastTime,
|
lastTime: settings.lastTime,
|
||||||
lastDay: settings.lastDay
|
lastDate: settings.lastDate
|
||||||
}, settings.disableOnAlarm);
|
}, settings.disableOnAlarm);
|
||||||
|
|
||||||
// return if no alarm is found
|
// return if no alarm is found
|
||||||
|
|
@ -133,7 +133,7 @@ exports = {
|
||||||
|
|
||||||
// save time of alarm and this day to prevent triggering for the same alarm again
|
// save time of alarm and this day to prevent triggering for the same alarm again
|
||||||
settings.lastTime = alarm.t;
|
settings.lastTime = alarm.t;
|
||||||
settings.lastDay = now.getDay();
|
settings.lastDate = now.getDay();
|
||||||
require("Storage").writeJSON("sleeplogalarm.settings.json", settings);
|
require("Storage").writeJSON("sleeplogalarm.settings.json", settings);
|
||||||
|
|
||||||
// write changes
|
// write changes
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
"id":"sleeplogalarm",
|
"id":"sleeplogalarm",
|
||||||
"name":"Sleep Log Alarm",
|
"name":"Sleep Log Alarm",
|
||||||
"shortName": "SleepLogAlarm",
|
"shortName": "SleepLogAlarm",
|
||||||
"version": "0.02",
|
"version": "0.03",
|
||||||
"description": "Enhance your morning and let your alarms wake you up when you are in light sleep.",
|
"description": "Enhance your morning and let your alarms wake you up when you are in light sleep.",
|
||||||
"icon": "app.png",
|
"icon": "app.png",
|
||||||
"type": "widget",
|
"type": "widget",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue