Skip to content

Commit

Permalink
widcal: fix memory leak
Browse files Browse the repository at this point in the history
Repeated redrawing would create multiple redraw-timeouts
  • Loading branch information
rigrig committed Apr 18, 2022
1 parent dc273a7 commit 4f17ed0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion apps/widcal/ChangeLog
@@ -1 +1,2 @@
0.01: First version
0.01: First version
0.02: Fix memory leak
2 changes: 1 addition & 1 deletion apps/widcal/metadata.json
@@ -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",
Expand Down
3 changes: 2 additions & 1 deletion apps/widcal/widget.js
Expand Up @@ -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);
}
};
})();

0 comments on commit 4f17ed0

Please sign in to comment.