This commit is contained in:
cv
2021-04-10 15:30:32 +02:00
parent 7293b0dfd9
commit a65f816477
4 changed files with 30 additions and 19 deletions
@@ -30,7 +30,7 @@ const size = {
width: 90,
};
export default function PlaybackControl(props) {
export default function PlaybackControl() {
const [playback, setPlayback] = useState(null);
const socket = useSocket();
const [timer, setTimer] = useState({
@@ -39,18 +39,25 @@ export default function PlaybackControl(props) {
expectedFinish: null,
});
// Torbjorn: why is this not updating?
useEffect(() => {
if (socket == null) return;
// Handle timer
socket.on('timer', (data) => {
console.log('websocket: got data', data);
setTimer({ ...data });
});
// Clear listener
return () => socket.off('timer');
}, [socket]);
// TO SEND TO SOCKET HERE WE CAN USE
// socket.emit('test')
// TODO: Move to playback API
// Soould this go through sockets?
const playbackControl = async (action, payload) => {
switch (action) {
case 'start': {