0.51: Fix long-touch to enable alarm/timer not updating time (fix #3804)

master
Gordon Williams 2025-04-28 12:40:31 +01:00
parent abb6f4896b
commit 0a67619541
3 changed files with 12 additions and 8 deletions

View File

@ -55,3 +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)

View File

@ -99,6 +99,7 @@ function showMainMenu(scroll, group, scrollback) {
onchange: (v, touch) => { onchange: (v, touch) => {
if (touch && (2==touch.type || 145<touch.x)) { // Long touch or touched icon. if (touch && (2==touch.type || 145<touch.x)) { // Long touch or touched icon.
e.on = v; e.on = v;
if (e.on) prepareForSave(e, index);
saveAndReload(); saveAndReload();
} else { } else {
setTimeout(e.timer ? showEditTimerMenu : showEditAlarmMenu, 10, e, index, undefined, scroller?scroller.scroll:undefined, group); setTimeout(e.timer ? showEditTimerMenu : showEditAlarmMenu, 10, e, index, undefined, scroller?scroller.scroll:undefined, group);
@ -328,6 +329,14 @@ function prepareAlarmForSave(alarm, alarmIndex, time, date, temp) {
} }
} }
function prepareForSave(alarm, alarmIndex) {
if (alarm.timer) {
prepareTimerForSave(alarm, alarmIndex, require("time_utils").decodeTime(alarm.timer));
} else {
prepareAlarmForSave(alarm, alarmIndex, require("time_utils").decodeTime(alarm.t));
}
}
function saveAndReload() { function saveAndReload() {
// Before saving revert the dow to the standard format (alarms only!) // Before saving revert the dow to the standard format (alarms only!)
alarms.filter(e => e.timer === undefined).forEach(a => a.dow = handleFirstDayOfWeek(a.dow)); alarms.filter(e => e.timer === undefined).forEach(a => a.dow = handleFirstDayOfWeek(a.dow));
@ -574,13 +583,7 @@ function enableAll(on) {
if (confirm) { if (confirm) {
alarms.forEach((alarm, i) => { alarms.forEach((alarm, i) => {
alarm.on = on; alarm.on = on;
if (on) { if (on) prepareForSave(alarm, i);
if (alarm.timer) {
prepareTimerForSave(alarm, i, require("time_utils").decodeTime(alarm.timer));
} else {
prepareAlarmForSave(alarm, i, require("time_utils").decodeTime(alarm.t));
}
}
}); });
saveAndReload(); saveAndReload();
showMainMenu(); showMainMenu();

View File

@ -2,7 +2,7 @@
"id": "alarm", "id": "alarm",
"name": "Alarms & Timers", "name": "Alarms & Timers",
"shortName": "Alarms", "shortName": "Alarms",
"version": "0.50", "version": "0.51",
"description": "Set alarms and timers on your Bangle", "description": "Set alarms and timers on your Bangle",
"icon": "app.png", "icon": "app.png",
"tags": "tool,alarm", "tags": "tool,alarm",