widmessages 0.07: Only load messages module if we have messages (30ms speed improvement)

pull/3624/head
Gordon Williams 2024-10-25 09:37:43 +01:00
parent e00cba4094
commit 4ff01d1db0
3 changed files with 5 additions and 4 deletions

View File

@ -5,3 +5,4 @@
0.04: Now shows message icons again (#2416)
0.05: Match draw() API e.g. to allow wid_edit to alter this widget
0.06: Fix bug that meant that only one widget was shown (now 3 unless changed in Settings->Apps->Messages->Widget messages)
0.07: Only load messages module if we have messages (30ms speed improvement)

View File

@ -1,7 +1,7 @@
{
"id": "widmessages",
"name": "Message Widget",
"version": "0.06",
"version": "0.07",
"description": "Widget showing new messages",
"icon": "app.png",
"type": "widget",

View File

@ -65,7 +65,7 @@ if ((require("Storage").readJSON("messages.settings.json", true) || {}).maxMessa
this.onMsg("show", {}); // reload messages+redraw
}
};
Bangle.on("message", WIDGETS["messages"].onMsg.bind(WIDGETS["messages"]));
if (require("Storage").read("messages.json")!==undefined) // only call init if we've got messages - otherwise we can avoid loading messages lib (saves 30ms)
WIDGETS["messages"].onMsg("init", {}); // abuse type="init" to prevent Bangle.drawWidgets();
}