fix(web): classic timer ran at 2x (idempotent startTimer) #96

Merged
funman300 merged 1 commits from fix/classic-timer-double-count into master 2026-06-24 00:18:53 +00:00
+5
View File
@@ -270,6 +270,11 @@ function startGame(seed) {
// ── Timer ──────────────────────────────────────────────────────────────────── // ── Timer ────────────────────────────────────────────────────────────────────
function startTimer() { function startTimer() {
// Idempotent: never stack a second interval. The visibilitychange handler
// and startGame can both call this, and a stray call (e.g. a load-time
// visibilitychange while a timer is already running) would otherwise leak
// the old interval and make elapsedSecs increment twice per second.
if (timerInterval) return;
timerInterval = setInterval(() => { timerInterval = setInterval(() => {
elapsedSecs++; elapsedSecs++;
updateTimerDisplay(); updateTimerDisplay();