sched: emit alarmReload, widalarm reload on alarmReload

pull/3232/head
Rob Pilling 2024-03-03 19:28:52 +00:00
parent a25ed8f6ff
commit 0dd67533ac
6 changed files with 11 additions and 6 deletions

View File

@ -24,3 +24,4 @@
0.21: Fix crash in clock_info
0.22: Dated event repeat option
0.23: Allow buzzing forever when an alarm fires
0.24: Emit alarmReload when alarms change (used by widalarm)

View File

@ -55,10 +55,7 @@ exports.getTimeToAlarm = function(alarm, time) {
/// Force a reload of the current alarms and widget
exports.reload = function() {
eval(require("Storage").read("sched.boot.js"));
if (global.WIDGETS && WIDGETS["alarm"]) {
WIDGETS["alarm"].reload();
Bangle.drawWidgets();
}
Bangle.emit("alarmReload");
};
// Factory that creates a new alarm with default values
exports.newDefaultAlarm = function () {

View File

@ -1,7 +1,7 @@
{
"id": "sched",
"name": "Scheduler",
"version": "0.23",
"version": "0.24",
"description": "Scheduling library for alarms and timers",
"icon": "app.png",
"type": "scheduler",

View File

@ -1 +1,2 @@
0.01: Moved out of 'alarm' app
0.02: Decouple reloading of widget when alarms change

View File

@ -1,7 +1,7 @@
{
"id": "widalarm",
"name": "Alarms Widget",
"version": "0.01",
"version": "0.02",
"description": "Displays an alarm icon in the widgets bar if any alarm is active",
"icon": "app.png",
"type": "widget",

View File

@ -6,3 +6,9 @@ WIDGETS["alarm"]={area:"tl",width:0,draw:function() {
}
};
WIDGETS["alarm"].reload();
Bangle.on("alarmReload", () => {
if (WIDGETS["alarm"]) {
WIDGETS["alarm"].reload();
Bangle.drawWidgets();
}
});