fix videochat
This commit is contained in:
parent
efd71694c6
commit
7beaa30e83
|
|
@ -19,6 +19,12 @@ export type IVideoChatShape = TLBaseShape<
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
|
|
||||||
|
interface DailyApiError {
|
||||||
|
error: string
|
||||||
|
info?: string
|
||||||
|
message?: string
|
||||||
|
}
|
||||||
|
|
||||||
// Simplified component using Daily Prebuilt
|
// Simplified component using Daily Prebuilt
|
||||||
const VideoChatComponent = ({ roomUrl }: { roomUrl: string }) => {
|
const VideoChatComponent = ({ roomUrl }: { roomUrl: string }) => {
|
||||||
const wrapperRef = useRef<HTMLDivElement>(null)
|
const wrapperRef = useRef<HTMLDivElement>(null)
|
||||||
|
|
@ -119,10 +125,10 @@ export class VideoChatShape extends BaseBoxShapeUtil<IVideoChatShape> {
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
const errorData = (await response.json()) as { message: string }
|
const errorData = (await response.json()) as DailyApiError
|
||||||
|
|
||||||
// If room already exists, construct the URL using the room name
|
// Handle the case where the room already exists
|
||||||
if (errorData.message.includes("already exists")) {
|
if (response.status === 409) {
|
||||||
const url = `https://${import.meta.env.VITE_DAILY_DOMAIN}/${roomName}`
|
const url = `https://${import.meta.env.VITE_DAILY_DOMAIN}/${roomName}`
|
||||||
this.editor.updateShape<IVideoChatShape>({
|
this.editor.updateShape<IVideoChatShape>({
|
||||||
id: shape.id,
|
id: shape.id,
|
||||||
|
|
@ -135,7 +141,9 @@ export class VideoChatShape extends BaseBoxShapeUtil<IVideoChatShape> {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new Error(errorData.message || "Failed to create room")
|
throw new Error(
|
||||||
|
errorData.message || errorData.info || "Failed to create room",
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const { url } = (await response.json()) as { url: string }
|
const { url } = (await response.json()) as { url: string }
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue