From 848540cfbff61def7165793f06a681cb0ce1630d Mon Sep 17 00:00:00 2001 From: joylessorchid Date: Tue, 24 Mar 2026 07:29:38 +0300 Subject: [PATCH] =?UTF-8?q?fix:=20auto-start=20room=20when=20host=20enters?= =?UTF-8?q?=20(WAITING=20=E2=86=92=20ACTIVE)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/room/[code]/page.tsx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/app/room/[code]/page.tsx b/src/app/room/[code]/page.tsx index f60ddab..0f993f6 100644 --- a/src/app/room/[code]/page.tsx +++ b/src/app/room/[code]/page.tsx @@ -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" },