up
This commit is contained in:
+10
-2
@@ -159,6 +159,7 @@ function initialTimer(): TimerState {
|
||||
}
|
||||
}
|
||||
export class Controller {
|
||||
onMusicEnded: ((report: Report) => void) | null = null
|
||||
state: State = {
|
||||
session: randomUUID(),
|
||||
sequence: 0,
|
||||
@@ -330,6 +331,11 @@ export class Controller {
|
||||
tick() {
|
||||
if (this.updateTimer()) this.broadcast()
|
||||
}
|
||||
synchronizeTimer(timer: Omit<TimerState, 'revision'>) {
|
||||
this.state.timer = { ...timer, revision: this.state.timer.revision + 1 }
|
||||
this.timerDeadline = timer.status === 'running' ? this.now() + timer.remainingMs : null
|
||||
this.broadcast()
|
||||
}
|
||||
setResults(value: unknown) {
|
||||
const key = this.state.catalog.key
|
||||
if (value !== null && !key) throw new Error('Сначала выберите пакет игры')
|
||||
@@ -578,8 +584,10 @@ export class Controller {
|
||||
this.measured.delete(report.channel)
|
||||
}
|
||||
if (report.status === 'ended') {
|
||||
if (report.channel === 'music') this.advance()
|
||||
else c.desired = 'paused'
|
||||
if (report.channel === 'music') {
|
||||
this.onMusicEnded?.(report)
|
||||
this.advance()
|
||||
} else c.desired = 'paused'
|
||||
}
|
||||
this.broadcast()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user