From 2fd53a83d816fd34e7650422dd69ca1bc0375fe6 Mon Sep 17 00:00:00 2001 From: Jeff Emmett <46964190+Jeff-Emmett@users.noreply.github.com> Date: Thu, 17 Oct 2024 14:54:23 -0400 Subject: [PATCH] good hygiene commit --- src/App.tsx | 1 + src/components/Board.tsx | 1 - src/shapes/VideoChatShapeUtil.tsx | 45 ++++++++++++++++++++++--------- 3 files changed, 33 insertions(+), 14 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index c649b53..740bd3b 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -58,6 +58,7 @@ export default function InteractiveShapeExample() { return (
(); // Ensure this is inside the Board component const roomId = slug || 'default-room'; // Declare roomId here diff --git a/src/shapes/VideoChatShapeUtil.tsx b/src/shapes/VideoChatShapeUtil.tsx index b46127c..1b3d7b0 100644 --- a/src/shapes/VideoChatShapeUtil.tsx +++ b/src/shapes/VideoChatShapeUtil.tsx @@ -28,9 +28,7 @@ export class VideoChatShape extends BaseBoxShapeUtil { } component(shape: IVideoChatShape) { - // Remove unused destructured props - // const [roomUrl, setRoomUrl] = useState(initialRoomUrl); // Use initialRoomUrl to avoid duplicate identifier - // const [roomUrl, setRoomUrl] = useState(roomId); // Use roomId instead + const [roomUrl, setRoomUrl] = useState(""); // Added roomUrl state const [isInRoom, setIsInRoom] = useState(false); const [error, setError] = useState(""); const [isLoading, setIsLoading] = useState(false); @@ -41,13 +39,14 @@ export class VideoChatShape extends BaseBoxShapeUtil { }, []); const joinRoom = async () => { + console.log("HI IM A CONSOLE TEST") setError(""); setIsLoading(true); try { const response = await fetch('/api/get-or-create-room', { method: 'GET' }); const data: { roomUrl?: string; error?: string } = await response.json(); // Explicitly type 'data' if (data.roomUrl) { - // setRoomUrl(data.roomUrl); // Remove this line + setRoomUrl(data.roomUrl); // Set the room URL setIsInRoom(true); } else { setError(data.error || "Failed to join room. Please try again."); @@ -61,19 +60,39 @@ export class VideoChatShape extends BaseBoxShapeUtil { const leaveRoom = () => { setIsInRoom(false); - // setRoomUrl(""); // Remove this line + setRoomUrl(""); // Clear the room URL }; return ( -
- {!isInRoom && ( // Show button if not in room - +
+

Whereby Video Chat Room

+ {isLoading ? ( +

Joining room...

+ ) : isInRoom ? ( +
+ +
+ +
+
+ ) : ( +
+ + {error &&

{error}

} +
)} - {/* Render Video Chat UI here when isInRoom is true */} - {isInRoom &&
Video Chat UI goes here
} +

+ View source: Val Town +

); } -} \ No newline at end of file +}