mirror of https://github.com/espruino/BangleApps
clock_info: expose a save (settings) method
parent
5173e1c578
commit
5be18f4261
|
@ -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: Expose a save() method on options
|
||||
|
|
|
@ -224,6 +224,12 @@ exports.addInteractive = function(menu, options) {
|
|||
options.menuB = b;
|
||||
}
|
||||
}
|
||||
options.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);
|
||||
};
|
||||
|
||||
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 +282,7 @@ 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);
|
||||
options.save();
|
||||
// On 2v18+ firmware we can stop other event handlers from being executed since we handled this
|
||||
E.stopEventPropagation&&E.stopEventPropagation();
|
||||
}
|
||||
|
|
|
@ -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",
|
||||
|
|
Loading…
Reference in New Issue