alarms: prevent timers (queued from main menu) from firing immediately

master
Rob Pilling 2025-04-25 12:12:49 +01:00
parent 491d36e73a
commit c29555cc53
2 changed files with 7 additions and 6 deletions

View File

@ -55,4 +55,4 @@
to select an alarm in the main menu. to select an alarm in the main menu.
0.50: Bangle.js 2: Long touch of alarm in main menu toggle it on/off. Touching the icon on 0.50: Bangle.js 2: Long touch of alarm in main menu toggle it on/off. Touching the icon on
the right will do the same. the right will do the same.
0.51: Fix long-touch to enable alarm/timer not updating time (fix #3804) 0.51: Fix long-touch to enable alarm/timer not updating time (fix #3804)

View File

@ -87,11 +87,10 @@ function showMainMenu(scroll, group, scrollback) {
}; };
const getGroups = settings.showGroup && !group; const getGroups = settings.showGroup && !group;
const groups = getGroups ? {} : undefined; const groups = getGroups ? {} : undefined;
var showAlarm;
const getIcon = (e)=>{return e.on ? (e.timer ? iconTimerOn : iconAlarmOn) : (e.timer ? iconTimerOff : iconAlarmOff);}; const getIcon = (e)=>{return e.on ? (e.timer ? iconTimerOn : iconAlarmOn) : (e.timer ? iconTimerOff : iconAlarmOff);};
alarms.forEach((e, index) => { alarms.forEach((e, index) => {
showAlarm = !settings.showGroup || (group ? e.group === group : !e.group); const showAlarm = !settings.showGroup || (group ? e.group === group : !e.group);
if(showAlarm) { if(showAlarm) {
const label = trimLabel(getLabel(e),40); const label = trimLabel(getLabel(e),40);
menu[label] = { menu[label] = {
@ -316,7 +315,7 @@ function showEditAlarmMenu(selectedAlarm, alarmIndex, withDate, scroll, group) {
} }
function prepareAlarmForSave(alarm, alarmIndex, time, date, temp) { function prepareAlarmForSave(alarm, alarmIndex, time, date, temp) {
alarm.t = require("time_utils").encodeTime(time); if(time != null) alarm.t = require("time_utils").encodeTime(time);
alarm.last = alarm.t < require("time_utils").getCurrentTimeMillis() ? new Date().getDate() : 0; alarm.last = alarm.t < require("time_utils").getCurrentTimeMillis() ? new Date().getDate() : 0;
if(date) alarm.date = date.toLocalISOString().slice(0,10); if(date) alarm.date = date.toLocalISOString().slice(0,10);
@ -548,8 +547,10 @@ function showEditTimerMenu(selectedTimer, timerIndex) {
} }
function prepareTimerForSave(timer, timerIndex, time, temp) { function prepareTimerForSave(timer, timerIndex, time, temp) {
timer.timer = require("time_utils").encodeTime(time); if (time != null) {
timer.t = (require("time_utils").getCurrentTimeMillis() + timer.timer) % 86400000; timer.timer = require("time_utils").encodeTime(time);
timer.t = (require("time_utils").getCurrentTimeMillis() + timer.timer) % 86400000;
}
timer.last = 0; timer.last = 0;
if (!temp) { if (!temp) {