fix: consistent timer unit (seconds) in ChoiceSystem first onUpdate

The first onUpdate call used raw milliseconds (e.g. total: 10000),
while subsequent ticks used seconds (total: 10). This caused the
progress bar to jump on the first interval tick.
This commit is contained in:
2026-06-07 18:53:05 +08:00
parent c61826e87c
commit 25ea9ce9fd

View File

@@ -25,13 +25,14 @@ export class ChoiceSystem {
const maxLimit = Math.max(...timed.map((c) => c.timeLimit!))
const maxLimitSec = maxLimit / 1000
this.timeLimit = maxLimit
this.elapsed = 0
this.onUpdate = onUpdate
this.onTimeout = onTimeout
const state: ChoiceTimerState = { total: maxLimit, remaining: maxLimit }
this.onUpdate(state)
this.onUpdate({ total: maxLimitSec, remaining: maxLimitSec })
this.timerId = setInterval(() => {
this.elapsed += this.tickMs