From c1d7a4ed735c3c2ec91c1e07ced8d271149e6fc2 Mon Sep 17 00:00:00 2001 From: Rob Pilling Date: Sat, 10 Jun 2023 21:30:40 +0100 Subject: [PATCH] sched: kick off timers on upload --- apps/sched/interface.html | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/apps/sched/interface.html b/apps/sched/interface.html index 5730b5741..b67029fa2 100644 --- a/apps/sched/interface.html +++ b/apps/sched/interface.html @@ -86,6 +86,16 @@ function eventToAlarm(event, offsetMs) { } function upload() { + // kick off all the (active) timers + const now = new Date(); + const currentTime = now.getHours()*3600000 + + now.getMinutes()*60000 + + now.getSeconds()*1000; + + for (const alarm of alarms) + if (alarm.timer != undefined && alarm.on) + alarm.t = currentTime + alarm.timer; + Util.showModal("Saving..."); Util.writeStorage("sched.json", JSON.stringify(alarms), () => { Puck.write(`\x10require("sched").reload();\n`, () => { @@ -125,9 +135,7 @@ function renderAlarm(alarm, exists) { tdType.textContent = "Timer"; inputTime.onchange = e => { alarm.timer = hmsToMs(inputTime.value); - const now = new Date(); - const currentTime = (now.getHours()*3600000)+(now.getMinutes()*60000)+(now.getSeconds()*1000); - alarm.t = currentTime + alarm.timer; + // alarm.t is set on upload }; } else { tdType.textContent = "Alarm";