Synchornization on join + chat bugfixes

This commit is contained in:
Kacper Maj 2021-01-27 12:53:18 +01:00
parent 797ec9dffc
commit 70eec145b7

26
src/utils/videos.js Normal file
View File

@ -0,0 +1,26 @@
const videos = [];
const addVideo = ({ room, videoID }) => {
const videoIsTheSame = videos.find((obj) => obj.videoID === videoID);
if (videoIsTheSame) return;
const index = videos.findIndex((object) => object.room === room);
if (index === -1) {
videos.push({ room, videoID });
console.log(videos);
return videos;
}
videos.splice(index, 1, { room, videoID });
console.log(videos);
return videos;
};
const getVideo = (room) => {
const video = videos.find((object) => object.room === room);
if (!video) return;
return video.videoID;
};
module.exports = {
addVideo,
getVideo,
};