From 943de6fca82356297041578150cb5936d874209f Mon Sep 17 00:00:00 2001 From: Rob Pilling Date: Thu, 19 Sep 2024 14:07:09 +0100 Subject: [PATCH] sched/clkinfo: tapping an alarm toggles it on/off --- apps/sched/ChangeLog | 1 + apps/sched/clkinfo.js | 10 ++++++++-- apps/sched/metadata.json | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/apps/sched/ChangeLog b/apps/sched/ChangeLog index 1b385c8eae..46cf02caa8 100644 --- a/apps/sched/ChangeLog +++ b/apps/sched/ChangeLog @@ -27,3 +27,4 @@ 0.24: Emit alarmReload when alarms change (used by widalarm) 0.25: Fix wrap around when snoozed through midnight 0.26: Fix hitting snooze on an alarm after when the snooze would've fired +0.27: Tapping clkinfo enables/disables the selected alarm diff --git a/apps/sched/clkinfo.js b/apps/sched/clkinfo.js index 89402ea677..0140e6067f 100644 --- a/apps/sched/clkinfo.js +++ b/apps/sched/clkinfo.js @@ -96,12 +96,13 @@ } var img = iconAlarmOn; + var all = alarm.getAlarms(); //get only alarms not created by other apps var alarmItems = { name: /*LANG*/"Alarms", img: img, dynamic: true, - items: alarm.getAlarms().filter(a=>!a.appid) + items: all.filter(a=>!a.appid) //.sort((a,b)=>alarm.getTimeToAlarm(a)-alarm.getTimeToAlarm(b)) .sort((a,b)=>getAlarmOrder(a)-getAlarmOrder(b)) .map((a, i)=>({ @@ -123,7 +124,12 @@ this.interval = undefined; this.switchTimeout = undefined; }, - run: function() { } + run: function() { + a.on = !a.on; + this.emit("redraw"); + alarm.setAlarms(all); + alarm.reload(); + } })), }; diff --git a/apps/sched/metadata.json b/apps/sched/metadata.json index be4dcdf332..591e9d3e90 100644 --- a/apps/sched/metadata.json +++ b/apps/sched/metadata.json @@ -1,7 +1,7 @@ { "id": "sched", "name": "Scheduler", - "version": "0.26", + "version": "0.27", "description": "Scheduling library for alarms and timers", "icon": "app.png", "type": "scheduler",