diff --git a/client/src/features/info/Info.jsx b/client/src/features/info/Info.jsx index ec9780518..961602649 100644 --- a/client/src/features/info/Info.jsx +++ b/client/src/features/info/Info.jsx @@ -1,15 +1,76 @@ +import { useEffect } from 'react'; +import { useSocket } from 'app/context/socketContext'; import style from './Info.module.css'; import InfoTitle from './InfoTitle'; import InfoLogger from './InfoLogger'; +import { useState } from 'react'; export default function Info() { - const data = {}; + const socket = useSocket(); + const [titles, setTitles] = useState({ + titleNow: '', + subtitleNow: '', + presenterNow: '', + noteNow: '', + titleNext: '', + subtitleNext: '', + presenterNext: '', + noteNext: '', + }); + const [selected, setSelected] = useState('-/-'); const logData = []; + + // handle incoming messages + useEffect(() => { + if (socket == null) return; + + // Ask for titles + socket.emit('get-titles'); + + // Handle titles + socket.on('titles', (data) => { + setTitles(data); + }); + + // Ask for selection data + socket.emit('get-selected'); + + // Handle selection data + socket.on('selected', (data) => { + const formatedCurrent = `${data.index != null ? data.index + 1 : '-'}/${ + data.total != null ? data.total : '-' + }`; + + setSelected(formatedCurrent); + }); + + // Clear listener + return () => { + socket.off('titles'); + socket.off('selected'); + }; + }, [socket]); + + // prepare data + const titlesNow = { + title: titles.titleNow, + subtitle: titles.subtitleNow, + presenter: titles.presenterNow, + note: titles.noteNow, + }; + + const titlesNext = { + title: titles.titleNext, + subtitle: titles.subtitleNext, + presenter: titles.presenterNext, + note: titles.noteNext, + }; + return ( <> -
Event 1/31
- - +
{`Event ${selected}`}
+ + ); diff --git a/client/src/features/info/InfoTitle.jsx b/client/src/features/info/InfoTitle.jsx index d77cddba6..0ce66ab8f 100644 --- a/client/src/features/info/InfoTitle.jsx +++ b/client/src/features/info/InfoTitle.jsx @@ -17,16 +17,20 @@ export default function InfoTitle(props) {
- Title: Demo title + Title: + {data.title}
- Subtitle: Demo Subtitle + Subtitle: + {data.subtitle}
- Presenter: Demo Presenter Name + Presenter: + {data.presenter}
- Notes: Demo Notes + Notes: + {data.note}
); diff --git a/server/src/classes/EventTimer.js b/server/src/classes/EventTimer.js index e7bc9c0f5..e6520bbba 100644 --- a/server/src/classes/EventTimer.js +++ b/server/src/classes/EventTimer.js @@ -44,9 +44,11 @@ export class EventTimer extends Timer { titleNow: null, subtitleNow: null, presenterNow: null, + noteNow: null, titleNext: null, subtitleNext: null, presenterNext: null, + noteNext: null, }; selectedEventIndex = null; @@ -93,6 +95,7 @@ export class EventTimer extends Timer { this.io.emit('selected', { id: this.selectedEventId, index: this.selectedEventIndex, + total: this.numEvents, }); this.io.emit('selected-id', this.selectedEventId); this.io.emit('next-id', this.nextEventId); @@ -289,6 +292,7 @@ export class EventTimer extends Timer { socket.emit('selected', { id: this.selectedEventId, index: this.selectedEventIndex, + total: this.numEvents, }); }); @@ -588,6 +592,7 @@ export class EventTimer extends Timer { this.titles.titleNow = e.title; this.titles.subtitleNow = e.subtitle; this.titles.presenterNow = e.presenter; + this.titles.noteNow = e.note; this.selectedEventId = e.id; break; @@ -601,6 +606,7 @@ export class EventTimer extends Timer { this.titles.titleNow = e.title; this.titles.subtitleNow = e.subtitle; this.titles.presenterNow = e.presenter; + this.titles.noteNow = e.note; this.selectedEventId = e.id; break; @@ -616,6 +622,7 @@ export class EventTimer extends Timer { this.titles.titleNext = e.title; this.titles.subtitleNext = e.subtitle; this.titles.presenterNext = e.presenter; + this.titles.noteNext = e.note; this.nextEventId = e.id; break; case 'next-public': @@ -628,6 +635,7 @@ export class EventTimer extends Timer { this.titles.titleNext = e.title; this.titles.subtitleNext = e.subtitle; this.titles.presenterNext = e.presenter; + this.titles.noteNext = e.note; this.nextEventId = e.id; break; @@ -644,6 +652,7 @@ export class EventTimer extends Timer { this.titles.titleNext = null; this.titles.subtitleNext = null; this.titles.presenterNext = null; + this.titles.noteNext = null; this.nextEventId = null; this.titlesPublic.titleNext = null; @@ -682,9 +691,11 @@ export class EventTimer extends Timer { titleNow: null, subtitleNow: null, presenterNow: null, + noteNow: null, titleNext: null, subtitleNext: null, presenterNext: null, + noteNext: null, }; this.publicTitles = { @@ -731,9 +742,11 @@ export class EventTimer extends Timer { Title Now = ${this.titles.titleNow} Subtitle Now = ${this.titles.subtitleNow} Presenter Now = ${this.titles.presenterNow} + Note Now = ${this.titles.noteNow} Title Next = ${this.titles.titleNext} Subtitle Next = ${this.titles.subtitleNext} Presenter Next = ${this.titles.presenterNext} + Note Next = ${this.titles.noteNext} Public Titles ------------------------------