fix: auto-start room when host enters (WAITING → ACTIVE)

This commit is contained in:
2026-03-24 07:29:38 +03:00
parent 4b6284b04d
commit 848540cfbf

View File

@@ -58,8 +58,20 @@ export default function RoomPage() {
const roomData = await res.json();
setRoom(roomData);
// If authenticated user is host and no token yet, fetch host token
// If authenticated user is host and no token yet
if (!token && userId && roomData.hostId === userId) {
// Auto-start room if still WAITING
if (roomData.status === "WAITING") {
const startRes = await fetch(`/api/rooms/${roomData.id}/start`, {
method: "POST",
});
if (startRes.ok) {
const startedRoom = await startRes.json();
setRoom({ ...roomData, status: startedRoom.status });
}
}
// Now fetch token
const tokenRes = await fetch("/api/livekit/token", {
method: "POST",
headers: { "Content-Type": "application/json" },