widcw: fix memory leak

Repeated redrawing would create multiple redraw-timeouts
pull/2064/head
Richard de Boer 2022-07-27 19:45:40 +02:00
parent 489582ee91
commit ded3b25d3e
No known key found for this signature in database
3 changed files with 5 additions and 4 deletions

View File

@ -1 +1,2 @@
0.01: First version
0.01: First version
0.02: Fix memory leak

View File

@ -1,7 +1,7 @@
{
"id": "widcw",
"name": "Calendar Week Widget",
"version": "0.01",
"version": "0.02",
"description": "Widget which shows the current calendar week",
"icon": "widget.png",
"type": "widget",

View File

@ -34,8 +34,8 @@
}
// redraw when date changes
setTimeout(()=>WIDGETS["widcw"].draw(), (86401 - Math.floor(date/1000) % 86400)*1000);
if (WIDGETS["widcw"].to) clearTimeout(WIDGETS["widcw"].to);
WIDGETS["widcw"].to = setTimeout(()=>WIDGETS["widcw"].draw(), (86401 - Math.floor(date/1000) % 86400)*1000);
}
// add your widget