fix: a screen's video no longer flickers and its button stays clickable while a timer redraws the screen
CI / frontend (push) Failing after 16s
CI / backend (push) Failing after 33s

MIST's cutscene screen has a 0.1s timer that changes a variable, and every change rebuilt the whole
screen: the <video> restarted each time and "Skip" was replaced between press and release, so the
click never landed. Videos (Movie(play=...) and the movie channel picture) are now kept per shown
screen and resumed if the browser paused them, and a redraw requested while a pointer is down waits
for its release.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
mrleo1nidandClaude Sonnet 5.5 committed 2026-10-26 04:05:58 +03:00
1 parent 16ba20816c
commit 8251fca9bf
2 files changed
+93 -20

No files matched your search

+24 -1
View File
@@ -7,7 +7,7 @@ import { parseHTML } from "linkedom";
const { window, document } = parseHTML("<!doctype html><html><body></body></html>");
Object.assign(globalThis, { window, document, HTMLElement: window.HTMLElement, HTMLInputElement: window.HTMLInputElement,
HTMLImageElement: window.HTMLImageElement, Image: window.Image });
HTMLImageElement: window.HTMLImageElement, HTMLVideoElement: window.HTMLVideoElement ?? class {}, Image: window.Image });
window.setTimeout = setTimeout;
window.clearTimeout = clearTimeout;
globalThis.requestAnimationFrame = (cb) => setTimeout(() => cb(performance.now()), 1);
@@ -271,3 +271,26 @@ test("an `if` that only sets properties picks the image; decompiled comma action
assert.equal(store.mood_clicked, 1);
assert.equal(store.mood_done, true);
});
test("a redraw keeps the playing video, and one held down button is not rebuilt under the pointer", async () => {
const movie = { w: "add", args: [{ k: "call", f: { k: "name", id: "Movie" }, a: [], kw: { play: { k: "const", v: "intro.webm" } } }],
props: {}, body: [] };
const { manager } = setup();
manager.screens.cutscene = { params: [], props: {}, defaults: [], body: [movie] };
manager.show("cutscene", [], {});
const first = manager.layer.querySelector("video");
assert.ok(first, "the video is on the screen");
for (let i = 0; i < 3; i++) { manager.refresh(); await wait(30); }
assert.equal(manager.layer.querySelector("video"), first, "the same <video> after redraws");
manager.hide("cutscene");
manager.show("cutscene", [], {});
assert.notEqual(manager.layer.querySelector("video"), first, "a screen shown again starts a new video");
// a redraw requested while a pointer is down waits for its release
window.dispatchEvent(new window.Event("pointerdown"));
const during = manager.layer.querySelector("video");
manager.refresh();
await wait(30);
assert.equal(manager.layer.querySelector("video"), during);
window.dispatchEvent(new window.Event("pointerup"));
await wait(30);
});