Skip to content

Commit

Permalink
Add disable video param
Browse files Browse the repository at this point in the history
  • Loading branch information
chunweii committed Oct 17, 2023
1 parent c5d56f9 commit d6615c7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion frontend/src/hooks/useCollaboration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { Room, connect } from "twilio-video";
type UseCollaborationProps = {
roomId: string;
userId: string;
disableVideo?: boolean;
};

enum SocketEvents {
Expand All @@ -23,7 +24,7 @@ enum SocketEvents {

var vers = 0;

const useCollaboration = ({ roomId, userId }: UseCollaborationProps) => {
const useCollaboration = ({ roomId, userId, disableVideo }: UseCollaborationProps) => {
const [socket, setSocket] = useState<Socket | null>(null);
const [text, setText] = useState<string>("#Write your solution here");
const [cursor, setCursor] = useState<number>(
Expand All @@ -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 }
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/pages/room/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down

0 comments on commit d6615c7

Please sign in to comment.