diff --git a/src/shapes/VideoChatShapeUtil.tsx b/src/shapes/VideoChatShapeUtil.tsx index ad087fb..c726779 100644 --- a/src/shapes/VideoChatShapeUtil.tsx +++ b/src/shapes/VideoChatShapeUtil.tsx @@ -30,7 +30,10 @@ export class VideoChatShape extends BaseBoxShapeUtil { } async ensureRoomExists(shape: IVideoChatShape) { - if (shape.props.roomUrl !== null) return + if (shape.props.roomUrl !== null) { + console.log("Room already exists:", shape.props.roomUrl) + return + } try { const apiKey = import.meta.env["VITE_DAILY_API_KEY"] @@ -51,6 +54,9 @@ export class VideoChatShape extends BaseBoxShapeUtil { }), }) + console.log("Response status:", response.status) + console.log("Response data:", await response.clone().json()) + if (!response.ok) throw new Error(`Failed to create room (${response.status})`) @@ -59,22 +65,35 @@ export class VideoChatShape extends BaseBoxShapeUtil { if (!url) throw new Error("Room URL is missing") - this.editor.updateShape({ + console.log("Room created successfully:", url) + console.log("Updating shape with new URL") + + await this.editor.updateShape({ id: shape.id, - type: "VideoChat", - props: { ...shape.props, roomUrl: url }, + type: shape.type, + props: { + ...shape.props, + roomUrl: url, + }, }) + + console.log("Shape updated:", this.editor.getShape(shape.id)) } catch (error) { - console.error("Failed to create Daily room:", error) + console.error("Error in ensureRoomExists:", error) throw error } } component(shape: IVideoChatShape) { const [hasPermissions, setHasPermissions] = useState(false) + const [error, setError] = useState(null) + const [isLoading, setIsLoading] = useState(true) useEffect(() => { - this.ensureRoomExists(shape).catch(console.error) + setIsLoading(true) + this.ensureRoomExists(shape) + .catch(console.error) + .finally(() => setIsLoading(false)) }, []) useEffect(() => { @@ -98,6 +117,10 @@ export class VideoChatShape extends BaseBoxShapeUtil { requestPermissions() }, [shape.props.allowCamera, shape.props.allowMicrophone]) + if (error) { + return
Error creating room: {error.message}
+ } + if (!shape.props.roomUrl) { return (
{ borderRadius: "4px", }} > - Creating room... + {isLoading ? "Creating room... Please wait" : "Creating room..."}
) } diff --git a/src/ui/overrides.tsx b/src/ui/overrides.tsx index 729516e..6ac8947 100644 --- a/src/ui/overrides.tsx +++ b/src/ui/overrides.tsx @@ -283,6 +283,7 @@ export const overrides: TLUiOverrides = { } }, }, + //TODO: MAKE THIS WORK, ADD USER PERMISSIONING TO JOIN BROADCAST? broadcastView: { id: "broadcast-view", label: "Broadcast View",