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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user