widcal: fix memory leak

Repeated redrawing would create multiple redraw-timeouts
pull/1713/head
Richard de Boer 2022-04-18 16:26:01 +02:00
parent dc273a7a12
commit 4f17ed02d6
No known key found for this signature in database
GPG Key ID: 8721727971871937
3 changed files with 5 additions and 3 deletions

View File

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

View File

@ -1,7 +1,7 @@
{
"id": "widcal",
"name": "Calendar Widget",
"version": "0.01",
"version": "0.02",
"description": "Widget with the current date",
"icon": "widget.png",
"type": "widget",

View File

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