fix: auto-start room when host enters (WAITING → ACTIVE)
This commit is contained in:
@@ -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" },
|
||||
|
||||
Reference in New Issue
Block a user