runplus: fix drawing of stat when zoomed

pull/3419/head
Rob Pilling 2024-05-16 21:13:57 +01:00
parent f543b86eae
commit 768437219e
1 changed files with 5 additions and 7 deletions

View File

@ -124,8 +124,7 @@ function zoom(statID) {
const onTouch = () => {
Bangle.removeListener("touch", onTouch);
Bangle.removeListener("twist", onTwist);
if (runInterval) clearInterval(runInterval);
runInterval = undefined;
stat.removeListener("changed", draw);
setScreen("main");
};
Bangle.on("touch", onTouch); // queued after layout's touchHandler (otherwise we'd be removed then instantly re-zoomed)
@ -135,7 +134,7 @@ function zoom(statID) {
};
Bangle.on("twist", onTwist);
const draw = () => {
const draw = stat => {
const R = Bangle.appRect;
g.reset()
@ -144,7 +143,6 @@ function zoom(statID) {
layout.render(layout.bottom);
const stat = exs.stats[statID];
g
.setFont(zoomFont)
.setColor(headingCol)
@ -154,9 +152,9 @@ function zoom(statID) {
};
layout.lazy = false; // restored when we go back to "main"
if (runInterval) clearInterval(runInterval);
runInterval = setInterval(draw, 1000);
draw();
const stat = exs.stats[statID];
stat.on("changed", draw);
draw(stat);
}
let lc = [];