indicate next

small improvements
This commit is contained in:
cv
2021-04-25 12:56:29 +02:00
parent fabdda8a59
commit 81e52d2831
3 changed files with 27 additions and 14 deletions
@@ -57,15 +57,20 @@ export default function EventList(props) {
// ask for playstate
socket.emit('get-selected-id');
socket.emit('get-next-id');
// Handle playstate
socket.on('selected-id', (data) => {
setSelected(data);
});
socket.on('next-id', (data) => {
setNext(data);
});
// Clear listener
return () => {
socket.off('selected-id');
socket.off('next-id');
};
}, [socket]);
@@ -76,6 +81,8 @@ export default function EventList(props) {
console.log('EventList: events in event list', events);
let cumulativeDelay = 0;
console.log('debug next id', next)
return (
<div className={style.eventContainer}>
{cursor === -1 && <div className={style.cursor} />}
@@ -90,7 +97,7 @@ export default function EventList(props) {
index={index}
data={e}
selected={selected === e.id}
next={next === index}
next={next === e.id}
eventsHandler={eventsHandler}
delay={cumulativeDelay}
/>
@@ -21,7 +21,7 @@ export default function EventListItem(props) {
index={index}
data={data}
selected={selected}
next={next === index}
next={next}
eventsHandler={eventsHandler}
delay={delay}
/>
+18 -12
View File
@@ -41,6 +41,7 @@ class EventTimer extends Timer {
selectedEvent = null;
selectedEventId = null;
nextEventId = null;
numEvents = null;
_eventlist = null;
@@ -78,6 +79,7 @@ class EventTimer extends Timer {
this.io.emit('timer', this.getObject());
this.io.emit('playstate', this.state);
this.io.emit('selected-id', this.selectedEventId);
this.io.emit('next-id', this.nextEventId);
this.io.emit('titles', this.titles);
}
@@ -205,6 +207,7 @@ class EventTimer extends Timer {
socket.emit('timer', this.getObject());
socket.emit('playstate', this.state);
socket.emit('selected-id', this.selectedEventId);
socket.emit('next-id', this.nextEventId);
socket.emit('titles', this.titles);
});
@@ -234,6 +237,10 @@ class EventTimer extends Timer {
socket.emit('selected-id', this.selectedEventId);
});
socket.on('get-next-id', () => {
socket.emit('next-id', this.nextEventId);
});
socket.on('get-titles', () => {
socket.emit('titles', this.titles);
});
@@ -371,19 +378,11 @@ class EventTimer extends Timer {
this.titles.titleNext = null;
this.titles.subtitleNext = null;
this.titles.presenterNext = null;
this.nextEventId = null;
// look for event after
if (eventIndex < this.numEvents - 1) {
for (let i = eventIndex + 1; i < this.numEvents; i++) {
// check that is the right type
if (this._eventList[i].type === 'event') {
this.titles.titleNext = this._eventList[i].title;
this.titles.subtitleNext = this._eventList[i].subtitle;
this.titles.presenterNext = this._eventList[i].presenter;
break;
}
}
}
this._loadNext(eventIndex);
this.broadcastState();
}
@@ -413,8 +412,15 @@ class EventTimer extends Timer {
this.titles.titleNext = null;
this.titles.subtitleNext = null;
this.titles.presenterNext = null;
this.nextEventId = null;
// look for event after
this._loadNext(eventIndex);
this.broadcastState();
}
_loadNext(eventIndex) {
if (eventIndex < this.numEvents - 1) {
for (let i = eventIndex + 1; i < this.numEvents; i++) {
// check that is the right type
@@ -422,11 +428,11 @@ class EventTimer extends Timer {
this.titles.titleNext = this._eventList[i].title;
this.titles.subtitleNext = this._eventList[i].subtitle;
this.titles.presenterNext = this._eventList[i].presenter;
this.nextEventId = this._eventList[i].id;
break;
}
}
}
this.broadcastState();
}
_resetSelection() {