messages 0.25: Fix widget memory usage issues if message received and watch repeatedly calls Bangle.drawWidgets (fix #1550)

master
Gordon Williams 2022-03-09 13:39:19 +00:00
parent eca4079828
commit e0937a942b
4 changed files with 10 additions and 4 deletions

View File

@ -2,7 +2,7 @@
"id": "gbridge", "id": "gbridge",
"name": "Gadgetbridge", "name": "Gadgetbridge",
"version": "0.26", "version": "0.26",
"description": "(NOT RECOMMENDED) Displays Gadgetbridge notifications from Android. Please use the 'Android' Bangle.js app instead.", "description": "(NOT RECOMMENDED) Displays Gadgetbridge notifications from Android. Please use the 'Android Integration' Bangle.js app instead.",
"icon": "app.png", "icon": "app.png",
"type": "widget", "type": "widget",
"tags": "tool,system,android,widget", "tags": "tool,system,android,widget",

View File

@ -37,3 +37,4 @@
0.23: Change message colors to match current theme instead of using green 0.23: Change message colors to match current theme instead of using green
Now attempt to use Large/Big/Medium fonts, and allow minimum font size to be configured Now attempt to use Large/Big/Medium fonts, and allow minimum font size to be configured
0.24: Remove left-over debug statement 0.24: Remove left-over debug statement
0.25: Fix widget memory usage issues if message received and watch repeatedly calls Bangle.drawWidgets (fix #1550)

View File

@ -1,7 +1,7 @@
{ {
"id": "messages", "id": "messages",
"name": "Messages", "name": "Messages",
"version": "0.24", "version": "0.25",
"description": "App to display notifications from iOS and Gadgetbridge/Android", "description": "App to display notifications from iOS and Gadgetbridge/Android",
"icon": "app.png", "icon": "app.png",
"type": "app", "type": "app",

View File

@ -1,5 +1,10 @@
WIDGETS["messages"]={area:"tl", width:0, iconwidth:24, WIDGETS["messages"]={area:"tl", width:0, iconwidth:24,
draw:function() { draw:function() {
// If we had a setTimeout queued from the last time we were called, remove it
if (WIDGETS["messages"].i) {
clearTimeout(WIDGETS["messages"].i);
delete WIDGETS["messages"].i;
}
Bangle.removeListener('touch', this.touch); Bangle.removeListener('touch', this.touch);
if (!this.width) return; if (!this.width) return;
var c = (Date.now()-this.t)/1000; var c = (Date.now()-this.t)/1000;
@ -11,7 +16,7 @@ draw:function() {
this.l = Date.now(); this.l = Date.now();
WIDGETS["messages"].buzz(); // buzz every 4 seconds WIDGETS["messages"].buzz(); // buzz every 4 seconds
} }
setTimeout(()=>WIDGETS["messages"].draw(), 1000); WIDGETS["messages"].i=setTimeout(()=>WIDGETS["messages"].draw(), 1000);
if (process.env.HWVERSION>1) Bangle.on('touch', this.touch); if (process.env.HWVERSION>1) Bangle.on('touch', this.touch);
},show:function(quiet) { },show:function(quiet) {
WIDGETS["messages"].t=Date.now(); // first time WIDGETS["messages"].t=Date.now(); // first time