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
broadcastState() {
this.io.emit('timer', this.getObject());
broadcastState(update = true) {
this.io.emit('timer', this.getObject(update));
this.io.emit('playstate', this.state);
this.io.emit('selected', {
id: this.selectedEventId,
@@ -241,7 +241,12 @@ export class EventTimer extends Timer {
this.current = this._finishAt - now;
} else {
// 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(update = true) {
// update timer
this.update();
if (update) this.update();
// update timetag
this.timeTag = stringFromMillis(this.current);