refract: broadcast state

- ability to broadcast state without recalculating timer
This commit is contained in:
cv
2021-10-31 11:20:35 +01:00
parent 5a68d292e1
commit 0bb728d76c
2 changed files with 10 additions and 5 deletions
+8 -3
View File
@@ -203,8 +203,8 @@ export class EventTimer extends Timer {
} }
// broadcast state // broadcast state
broadcastState() { broadcastState(update = true) {
this.io.emit('timer', this.getObject()); this.io.emit('timer', this.getObject(update));
this.io.emit('playstate', this.state); this.io.emit('playstate', this.state);
this.io.emit('selected', { this.io.emit('selected', {
id: this.selectedEventId, id: this.selectedEventId,
@@ -241,7 +241,12 @@ export class EventTimer extends Timer {
this.current = this._finishAt - now; this.current = this._finishAt - now;
} else { } else {
// look for event if none is loaded // look for event if none is loaded
if (this.current <= 0 || this.secondaryTimer <= 0) this.rollLoad(); if (this.current <= 0 || this.secondaryTimer <= 0) {
const newState = this.rollLoad();
// broadcast state without recalling timer
if (newState) this.broadcastState(false);
}
} }
} }
+2 -2
View File
@@ -136,9 +136,9 @@ export class Timer {
} }
// getObject // getObject
getObject() { getObject(update = true) {
// update timer // update timer
this.update(); if (update) this.update();
// update timetag // update timetag
this.timeTag = stringFromMillis(this.current); this.timeTag = stringFromMillis(this.current);