diff --git a/apps/clock_info/ChangeLog b/apps/clock_info/ChangeLog index 97e62e238..a4c25f995 100644 --- a/apps/clock_info/ChangeLog +++ b/apps/clock_info/ChangeLog @@ -7,3 +7,4 @@ 0.06: When >1 clockinfo, swiping one back tries to ensure they don't display the same thing 0.07: Developer tweak: clkinfo load errors are emitted 0.08: Pass options to show(), hide() and run(), and add focus() and blur() item methods +0.09: Save clkinfo settings on kill and remove diff --git a/apps/clock_info/lib.js b/apps/clock_info/lib.js index d35ac5cf0..7b4e49b5c 100644 --- a/apps/clock_info/lib.js +++ b/apps/clock_info/lib.js @@ -224,6 +224,13 @@ exports.addInteractive = function(menu, options) { options.menuB = b; } } + const save = () => { + // save the currently showing clock_info + const settings = exports.loadSettings(); + settings.apps[appName] = {a:options.menuA, b:options.menuB}; + require("Storage").writeJSON("clock_info.json",settings); + }; + E.on("kill", save); if (options.menuA===undefined) options.menuA = 0; if (options.menuB===undefined) options.menuB = Math.min(exports.loadCount, menu[options.menuA].items.length)-1; @@ -276,10 +283,6 @@ exports.addInteractive = function(menu, options) { oldMenuItem.removeAllListeners("draw"); menuShowItem(menu[options.menuA].items[options.menuB]); } - // save the currently showing clock_info - let settings = exports.loadSettings(); - settings.apps[appName] = {a:options.menuA,b:options.menuB}; - require("Storage").writeJSON("clock_info.json",settings); // On 2v18+ firmware we can stop other event handlers from being executed since we handled this E.stopEventPropagation&&E.stopEventPropagation(); } @@ -333,6 +336,8 @@ exports.addInteractive = function(menu, options) { menuShowItem(menu[options.menuA].items[options.menuB]); // return an object with info that can be used to remove the info options.remove = function() { + save(); + E.removeListener("kill", save); Bangle.removeListener("swipe",swipeHandler); if (touchHandler) Bangle.removeListener("touch",touchHandler); if (lockHandler) Bangle.removeListener("lock", lockHandler); diff --git a/apps/clock_info/metadata.json b/apps/clock_info/metadata.json index 351425a8f..d2a5540e1 100644 --- a/apps/clock_info/metadata.json +++ b/apps/clock_info/metadata.json @@ -1,7 +1,7 @@ { "id": "clock_info", "name": "Clock Info Module", "shortName": "Clock Info", - "version":"0.08", + "version":"0.09", "description": "A library used by clocks to provide extra information on the clock face (Altitude, BPM, etc)", "icon": "app.png", "type": "module",