From eb20849bd85314bbb92154085bf803037fe6fa5d Mon Sep 17 00:00:00 2001 From: Adrian Wannenmacher Date: Tue, 10 Mar 2026 00:34:45 +0100 Subject: [PATCH] make main buttons redraw syncronously By main buttons I mean the "new game", "they win" and "we win" buttons. They have in common that they scroll to the bottom of the view, to make sure the user can immediately see their effect. This change fixes two bugs: 1. The scrolling did not work reliably. While it would always scroll a bit, it would usually not go to the bottom exactly. This meant that most of the time the bottom digits were only half visible. Now it scrolls reliably all the way. 2. When hitting the win buttons in rapid succession it was possible to trigger both within a single redraw cycle. This caused the UI to set a single rounds winner to both teams, which the round model rightly rejected. Now, by the time the second event is registered, the button has already been disabled, or the round been replaced by a new one. --- ui/round.js | 8 ++++++-- ui/session.js | 4 +++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ui/round.js b/ui/round.js index d7869dc..d1e9da4 100644 --- a/ui/round.js +++ b/ui/round.js @@ -25,8 +25,10 @@ export default class RoundView { ), m("button.wb-button.theywin._positioned", { - onclick: () => { + onclick: (event) => { + event.redraw = false; model.winner = Team.They; + m.redraw.sync(); window.scrollTo({ top: document.body.scrollHeight, behavior: "smooth", @@ -38,8 +40,10 @@ export default class RoundView { ), m("button.wb-button.wewin._positioned", { - onclick: () => { + onclick: (event) => { + event.redraw = false; model.winner = Team.We; + m.redraw.sync(); window.scrollTo({ top: document.body.scrollHeight, behavior: "smooth", diff --git a/ui/session.js b/ui/session.js index f3515db..c5073d0 100644 --- a/ui/session.js +++ b/ui/session.js @@ -62,8 +62,10 @@ export default class SessionView { : m( "button.wb-button._positioned", { - onclick: () => { + onclick: (event) => { + event.redraw = false; model.anotherGame(); + m.redraw.sync(); window.scrollTo({ top: document.body.scrollHeight, behavior: "smooth",