Synchornization on join + chat bugfixes
This commit is contained in:
parent
797ec9dffc
commit
70eec145b7
26
src/utils/videos.js
Normal file
26
src/utils/videos.js
Normal 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,
|
||||
};
|
Loading…
Reference in New Issue
Block a user