Skip to content

Commit

Permalink
[Alarms & Timers] Fix dow handling for timers
Browse files Browse the repository at this point in the history
  • Loading branch information
alessandrococco committed May 25, 2022
1 parent 67716ae commit 280fd5e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions apps/alarm/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ function handleFirstDayOfWeek(dow) {
return dow;
}

// Check the first day of week and update the dow field accordingly.
alarms.forEach(alarm => alarm.dow = handleFirstDayOfWeek(alarm.dow));
// Check the first day of week and update the dow field accordingly (alarms only!)
alarms.filter(e => e.timer === undefined).forEach(a => a.dow = handleFirstDayOfWeek(a.dow));

function showMainMenu() {
const menu = {
Expand Down Expand Up @@ -158,14 +158,14 @@ function saveAlarm(alarm, alarmIndex, time) {
}

function saveAndReload() {
// Before saving revert the dow to the standard format
alarms.forEach(a => a.dow = handleFirstDayOfWeek(a.dow, firstDayOfWeek));
// Before saving revert the dow to the standard format (alarms only!)
alarms.filter(e => e.timer === undefined).forEach(a => a.dow = handleFirstDayOfWeek(a.dow));

require("sched").setAlarms(alarms);
require("sched").reload();

// Fix after save
alarms.forEach(a => a.dow = handleFirstDayOfWeek(a.dow, firstDayOfWeek));
alarms.filter(e => e.timer === undefined).forEach(a => a.dow = handleFirstDayOfWeek(a.dow));
}

function decodeDOW(alarm) {
Expand Down

0 comments on commit 280fd5e

Please sign in to comment.