From 5b967184b671315b2d474e1f5eefeff9073c1bb0 Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Thu, 2 Dec 2021 10:07:45 +0000 Subject: [PATCH] 0.03: Fix unfreed memory, and clearInterval that disabled all clocks at midnight (fix #946) Fix app icon Change menu order so 'back' is at the top --- apps.json | 4 ++-- apps/qalarm/ChangeLog | 5 ++++- apps/qalarm/app-icon.js | 2 +- apps/qalarm/app.js | 10 +++++----- apps/qalarm/boot.js | 2 +- apps/qalarm/qalarmcheck.js | 9 ++++++--- 6 files changed, 19 insertions(+), 13 deletions(-) diff --git a/apps.json b/apps.json index a72ccdfc1..95a6feab5 100644 --- a/apps.json +++ b/apps.json @@ -4310,7 +4310,7 @@ "name": "Q Alarm and Timer", "shortName": "Q Alarm", "icon": "app.png", - "version": "0.02", + "version": "0.03", "description": "Alarm and timer app with days of week and 'hard' option.", "tags": "tool,alarm,widget", "supports": ["BANGLEJS", "BANGLEJS2"], @@ -4535,7 +4535,7 @@ "description": "Simple app to power off your Bangle.js", "icon": "app.png", "tags": "poweroff, shutdown", - "supports" : ["BANGLEJS", "BANGLEJS2"], + "supports" : ["BANGLEJS", "BANGLEJS2"], "readme": "README.md", "storage": [ {"name":"poweroff.app.js","url":"app.js"}, diff --git a/apps/qalarm/ChangeLog b/apps/qalarm/ChangeLog index 135e69d23..fb6c751bb 100644 --- a/apps/qalarm/ChangeLog +++ b/apps/qalarm/ChangeLog @@ -1,2 +1,5 @@ 0.01: First version! -0.02: Fixed alarms not working and localised days of week. \ No newline at end of file +0.02: Fixed alarms not working and localised days of week. +0.03: Fix unfreed memory, and clearInterval that disabled all clocks at midnight + Fix app icon + Change menu order so 'back' is at the top diff --git a/apps/qalarm/app-icon.js b/apps/qalarm/app-icon.js index 1a014b796..12d2c103f 100644 --- a/apps/qalarm/app-icon.js +++ b/apps/qalarm/app-icon.js @@ -1 +1 @@ -require("heatshrink").decompress(atob("/wA/AH4A/AH4AF0WiF1wwtF73GB53MAAgkY4wABFqIxPEhQuXGB4vUFxYwMEpBpGBwouNGAwfFF5I1KF6ZQHGAwNLFx4wHF/4v/F/4v/AoYGDF6gaFF5AwHL7QuMBJQvWEpwvxBQ4uRGBAkJT4wuWGBIuIRjKRNF8wwXFy4wWFzIwU53NFzPN5wuR5/PGK4tBDYSNQ5wVCCwIzBAAQoIAAQWGSJ5HFDYYAQIYTCRKRIeBAAYmDAAZsJMCQAbeCAybFiQ0XFTQAIzgAGFcYvz0QAGF84wGF1AwFF1QA/AH4A/ADQ=")) +require("heatshrink").decompress(atob("mEw4UA///gH+93+oH9Jf8AgfABZMP+ALRmADCitUAgUMAQP8AQMBqtVoAFBn4CBDwUFBYNQFAQLEioLBEgQLBgfwE4IKBAAI3BBYXAE4ILE/gJBAIM8HQQ8CngL/n4LFKYR3BhgLFNYSDCBYqPFBZKzBUwSoDWYTLBUwSoDZYQABBQa0DBZCoBAAY6EcojhEHgoACkoLFrALD1WVBQdW1QLDtQMDBQOpHQmqAAg8DIwQKEJAg6FMApfLDIoJFAAX//4KIBbE/aAIAIh7oBAH4A==")) diff --git a/apps/qalarm/app.js b/apps/qalarm/app.js index 64f601bf6..ad071adf0 100644 --- a/apps/qalarm/app.js +++ b/apps/qalarm/app.js @@ -41,6 +41,7 @@ function getCurrentTime() { function showMainMenu() { const menu = { "": { title: "Alarms" }, + "< Back" : () => load(), "New Alarm": () => showEditAlarmMenu(-1), "New Timer": () => showEditTimerMenu(-1), }; @@ -54,9 +55,7 @@ function showMainMenu() { else showEditAlarmMenu(idx); }; }); - menu["< Back"] = () => { - load(); - }; + menu if (WIDGETS["qalarm"]) WIDGETS["qalarm"].reload(); return E.showMenu(menu); @@ -86,6 +85,7 @@ function showEditAlarmMenu(alarmIndex, alarm) { const menu = { "": { title: alarm.msg ? alarm.msg : "Alarms" }, + "< Back" : showMainMenu, Hours: { value: hrs, onchange: function (v) { @@ -162,7 +162,6 @@ function showEditAlarmMenu(alarmIndex, alarm) { showMainMenu(); }; } - menu["< Back"] = showMainMenu; return E.showMenu(menu); } @@ -206,6 +205,7 @@ function showEditTimerMenu(timerIndex) { const menu = { "": { title: "Timer" }, + "< Back" : showMainMenu, Hours: { value: hrs, onchange: function (v) { @@ -264,7 +264,7 @@ function showEditTimerMenu(timerIndex) { showMainMenu(); }; } - menu["< Back"] = showMainMenu; + return E.showMenu(menu); } diff --git a/apps/qalarm/boot.js b/apps/qalarm/boot.js index 6713ad9e1..5e9560ee2 100644 --- a/apps/qalarm/boot.js +++ b/apps/qalarm/boot.js @@ -1 +1 @@ -eval(require("Storage").read("qalarmcheck.js")); +(function() { eval(require("Storage").read("qalarmcheck.js")); })() diff --git a/apps/qalarm/qalarmcheck.js b/apps/qalarm/qalarmcheck.js index 9a3f10d5e..8dac43800 100644 --- a/apps/qalarm/qalarmcheck.js +++ b/apps/qalarm/qalarmcheck.js @@ -4,7 +4,10 @@ print("Checking for alarms..."); -clearInterval(); +if (Bangle.QALARM) { + clearInterval(Bangle.QALARM); + Bangle.QALARM = undefined; +} function getCurrentTime() { let time = new Date(); @@ -29,13 +32,13 @@ let nextAlarms = (require("Storage").readJSON("qalarm.json", 1) || []) .sort((a, b) => a.t - b.t); if (nextAlarms[0]) { - setTimeout(() => { + Bangle.QALARM = setTimeout(() => { eval(require("Storage").read("qalarmcheck.js")); load("qalarm.js"); }, nextAlarms[0].t - t); } else { // No alarms found: will re-check at midnight - setTimeout(() => { + Bangle.QALARM = setTimeout(() => { eval(require("Storage").read("qalarmcheck.js")); }, 86400000 - t); }