mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-22 07:29:08 +00:00
roll()
timer has roll() implementation
This commit is contained in:
@@ -12,7 +12,6 @@ export default function RollIconBtn(props) {
|
|||||||
width={120}
|
width={120}
|
||||||
_focus={{ boxShadow: 'none' }}
|
_focus={{ boxShadow: 'none' }}
|
||||||
{...rest}
|
{...rest}
|
||||||
disabled
|
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -109,8 +109,28 @@ class EventTimer extends Timer {
|
|||||||
|
|
||||||
update() {
|
update() {
|
||||||
// if there is nothing selected, no nothing
|
// if there is nothing selected, no nothing
|
||||||
if (this.selectedEventId == null) return;
|
if (this.selectedEventId == null && this.state !== 'roll') return;
|
||||||
super.update();
|
|
||||||
|
// only implement roll here
|
||||||
|
if (this.state !== 'roll') {
|
||||||
|
super.update();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// get current time
|
||||||
|
const now = this._getCurrentTime();
|
||||||
|
this.clock = now;
|
||||||
|
|
||||||
|
if (this.selectedEventId == null) {
|
||||||
|
// look for event if none is loaded
|
||||||
|
this.rollLoad();
|
||||||
|
} else if (now > this._finishAt) {
|
||||||
|
// look for new if finished
|
||||||
|
this.rollLoad();
|
||||||
|
} else {
|
||||||
|
// update timer as usual
|
||||||
|
this.current = this._finishAt - now;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
@@ -140,9 +160,7 @@ class EventTimer extends Timer {
|
|||||||
else if (payload === 'next') this.next();
|
else if (payload === 'next') this.next();
|
||||||
else if (payload === 'reload') this.reload();
|
else if (payload === 'reload') this.reload();
|
||||||
else if (payload === 'unload') this.unload();
|
else if (payload === 'unload') this.unload();
|
||||||
|
else if (payload === 'roll') this.roll();
|
||||||
// Not yet implemented
|
|
||||||
// else if (payload === 'roll') this.roll();
|
|
||||||
|
|
||||||
this.broadcastThis('playstate', this.state);
|
this.broadcastThis('playstate', this.state);
|
||||||
this.broadcastThis('selected-id', this.selectedEventId);
|
this.broadcastThis('selected-id', this.selectedEventId);
|
||||||
@@ -730,10 +748,44 @@ class EventTimer extends Timer {
|
|||||||
this.broadcastState();
|
this.broadcastState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rollLoad() {
|
||||||
|
const now = this._getCurrentTime();
|
||||||
|
this._resetTimers(true);
|
||||||
|
this._resetSelection();
|
||||||
|
|
||||||
|
// loop through events, look for where we should be
|
||||||
|
for (const [index, e] of this._eventlist.entries()) {
|
||||||
|
if (e.timeStart <= now && now < e.timeEnd) {
|
||||||
|
// set timers
|
||||||
|
this._startedAt = e.timeStart;
|
||||||
|
this._finishAt = e.timeEnd;
|
||||||
|
this.duration = e.timeEnd - e.timeStart;
|
||||||
|
this.current = e.timeEnd - now;
|
||||||
|
|
||||||
|
// set selection
|
||||||
|
this.selectedEventId = e.id;
|
||||||
|
this.selectedEventIndex = index;
|
||||||
|
|
||||||
|
// set titles
|
||||||
|
this._loadTitlesNow();
|
||||||
|
this._loadTitlesNext();
|
||||||
|
// exit
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
roll() {
|
roll() {
|
||||||
console.log('roll: not yet implemented');
|
// do we need to change
|
||||||
return false;
|
if (this.state === 'roll') return;
|
||||||
|
|
||||||
|
// load into event
|
||||||
|
this.rollLoad();
|
||||||
|
|
||||||
|
// set state
|
||||||
this.state = 'roll';
|
this.state = 'roll';
|
||||||
|
|
||||||
|
this.broadcastState();
|
||||||
}
|
}
|
||||||
|
|
||||||
previous() {
|
previous() {
|
||||||
|
|||||||
@@ -110,7 +110,8 @@ class Timer {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
_resetTimers() {
|
_resetTimers(total = false) {
|
||||||
|
if (total) this.duration = null;
|
||||||
this.current = this.duration;
|
this.current = this.duration;
|
||||||
this._finishAt = null;
|
this._finishAt = null;
|
||||||
this._finishedAt = null;
|
this._finishedAt = null;
|
||||||
|
|||||||
Reference in New Issue
Block a user