mirror of https://github.com/espruino/BangleApps
clock_info 0.13: Cache loaded ClockInfos so if we have clockInfoWidget and a clock, we don't load them twice (saves ~300ms)
parent
c893bc849f
commit
66b0edf6c2
|
@ -11,3 +11,4 @@
|
|||
0.10: Fix focus bug when changing focus between two clock infos
|
||||
0.11: Prepend swipe listener if possible
|
||||
0.12: Add drawFilledImage to allow drawing icons with a separately coloured middle
|
||||
0.13: Cache loaded ClockInfos so if we have clockInfoWidget and a clock, we don't load them twice (saves ~300ms)
|
|
@ -14,6 +14,8 @@ if (stepGoal == undefined) {
|
|||
exports.loadCount = 0;
|
||||
/// A list of all the instances returned by addInteractive
|
||||
exports.clockInfos = [];
|
||||
/// A list of loaded clockInfos
|
||||
exports.clockInfoMenus = undefined;
|
||||
|
||||
/// Load the settings, with defaults
|
||||
exports.loadSettings = function() {
|
||||
|
@ -29,6 +31,8 @@ exports.loadSettings = function() {
|
|||
|
||||
/// Load a list of ClockInfos - this does not cache and reloads each time
|
||||
exports.load = function() {
|
||||
if (exports.clockInfoMenus)
|
||||
return exports.clockInfoMenus;
|
||||
var settings = exports.loadSettings();
|
||||
delete settings.apps; // keep just the basic settings in memory
|
||||
// info used for drawing...
|
||||
|
@ -146,6 +150,7 @@ exports.load = function() {
|
|||
});
|
||||
|
||||
// return it all!
|
||||
exports.clockInfoMenus = menu;
|
||||
return menu;
|
||||
};
|
||||
|
||||
|
@ -345,6 +350,9 @@ exports.addInteractive = function(menu, options) {
|
|||
menuHideItem(menu[options.menuA].items[options.menuB]);
|
||||
exports.loadCount--;
|
||||
delete exports.clockInfos[options.index];
|
||||
// If nothing loaded now, clear our list of loaded menus
|
||||
if (exports.loadCount==0)
|
||||
exports.clockInfoMenus = undefined;
|
||||
};
|
||||
options.redraw = function() {
|
||||
drawItem(menu[options.menuA].items[options.menuB]);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{ "id": "clock_info",
|
||||
"name": "Clock Info Module",
|
||||
"shortName": "Clock Info",
|
||||
"version":"0.12",
|
||||
"version":"0.13",
|
||||
"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