diff --git a/frontend/src/hooks/useCollaboration.tsx b/frontend/src/hooks/useCollaboration.tsx index 237790ab..eca5cead 100644 --- a/frontend/src/hooks/useCollaboration.tsx +++ b/frontend/src/hooks/useCollaboration.tsx @@ -11,6 +11,7 @@ import { Room, connect } from "twilio-video"; type UseCollaborationProps = { roomId: string; userId: string; + disableVideo?: boolean; }; enum SocketEvents { @@ -23,7 +24,7 @@ enum SocketEvents { var vers = 0; -const useCollaboration = ({ roomId, userId }: UseCollaborationProps) => { +const useCollaboration = ({ roomId, userId, disableVideo }: UseCollaborationProps) => { const [socket, setSocket] = useState(null); const [text, setText] = useState("#Write your solution here"); const [cursor, setCursor] = useState( @@ -48,6 +49,7 @@ const useCollaboration = ({ roomId, userId }: UseCollaborationProps) => { socketConnection.on("twilio-token", (token: string) => { twilioTokenRef.current = token; + if (disableVideo) return; connect(token, { name: roomId, audio: true, video: { width: 640, height: 480, frameRate: 24 } diff --git a/frontend/src/pages/room/[id].tsx b/frontend/src/pages/room/[id].tsx index 0e2e3217..bc5cf145 100644 --- a/frontend/src/pages/room/[id].tsx +++ b/frontend/src/pages/room/[id].tsx @@ -12,10 +12,12 @@ export default function Room() { const roomId = router.query.id as string; const userId = router.query.userId as string || "user1"; + const disableVideo = (router.query.disableVideo as string)?.toLowerCase() === "true"; const { text, setText, cursor, setCursor, room } = useCollaboration({ roomId: roomId as string, userId, + disableVideo, }); const question: Question = {