Skip to content

armgit / meet

Public Imported from GitHub
0

Open source video conferencing app powered by LiveKit. Built with Django and React.

πŸ”’οΈ(frontend) send the display name in the join request body

briquet6af43ebf1d38
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 56181412..2c3f1786 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -23,11 +23,13 @@ and this project adheres to
- ⬆️(agents) update python dependencies
- ⬆️(summary) update python dependencies
- πŸ”’οΈ(backend) issue room access tokens via POST rooms/{id}/join/ only
+- πŸ”’οΈ(frontend) send the display name in the join request body
### Fixed
- πŸ›(frontend) show a page when the connection ends unexpectedly
- πŸ›(frontend) show the transcript mic hint when every mic is muted
+- πŸ›(frontend) send users who cannot enter directly back to the lobby
## [1.37.0] - 2026-11-01
diff --git a/src/frontend/src/features/home/components/CreateMeetingMenu.tsx b/src/frontend/src/features/home/components/CreateMeetingMenu.tsx
index 99ab3e9a..34b4fc39 100644
--- a/src/frontend/src/features/home/components/CreateMeetingMenu.tsx
+++ b/src/frontend/src/features/home/components/CreateMeetingMenu.tsx
@@ -9,12 +9,8 @@ import { useState } from 'react'
import { menuRecipe } from '@/primitives/menuRecipe'
import { ApiRoom } from '@/features/rooms/api/ApiRoom'
-import { useSnapshot } from 'valtio'
-import { userStore } from '@/stores/user'
export const CreateMeetingMenu = () => {
- const { username } = useSnapshot(userStore)
-
const { t } = useTranslation('home')
const { mutateAsync: createRoom } = useCreateRoom()
const [laterRoom, setLaterRoom] = useState<null | ApiRoom>(null)
@@ -30,9 +26,9 @@ export const CreateMeetingMenu = () => {
className={menuRecipe({ icon: true, variant: 'light' }).item}
onAction={() => {
const slug = generateRoomId()
- createRoom({ slug, username }).then((data) =>
+ createRoom({ slug }).then((data) =>
navigateTo('room', data.slug, {
- state: { create: true, initialRoomData: data },
+ state: { create: true },
})
)
}}
@@ -45,7 +41,7 @@ export const CreateMeetingMenu = () => {
className={menuRecipe({ icon: true, variant: 'light' }).item}
onAction={() => {
const slug = generateRoomId()
- createRoom({ slug, username }).then(setLaterRoom)
+ createRoom({ slug }).then(setLaterRoom)
}}
data-attr="create-option-later"
>
diff --git a/src/frontend/src/features/rooms/api/createRoom.ts b/src/frontend/src/features/rooms/api/createRoom.ts
index 1ea845da..2601d770 100644
--- a/src/frontend/src/features/rooms/api/createRoom.ts
+++ b/src/frontend/src/features/rooms/api/createRoom.ts
@@ -6,15 +6,13 @@ import type { ApiRoom } from './ApiRoom'
export interface CreateRoomParams {
slug: string
callbackId?: string
- username?: string
}
const createRoom = ({
slug,
callbackId,
- username = '',
}: CreateRoomParams): Promise<ApiRoom> => {
- return fetchApi(`rooms/?username=${encodeURIComponent(username)}`, {
+ return fetchApi('rooms/', {
method: 'POST',
body: JSON.stringify({
name: slug,
diff --git a/src/frontend/src/features/rooms/api/fetchRoom.ts b/src/frontend/src/features/rooms/api/fetchRoom.ts
index 5a091711..e9383251 100644
--- a/src/frontend/src/features/rooms/api/fetchRoom.ts
+++ b/src/frontend/src/features/rooms/api/fetchRoom.ts
@@ -1,14 +1,6 @@
import { type ApiRoom } from './ApiRoom'
import { fetchApi } from '@/api/fetchApi'
-export const fetchRoom = ({
- roomId,
- username,
-}: {
- roomId: string
- username?: string
-}) => {
- const query = username ? `?username=${encodeURIComponent(username)}` : ''
-
- return fetchApi<ApiRoom>(`/rooms/${roomId}/${query}`)
+export const fetchRoom = ({ roomId }: { roomId: string }) => {
+ return fetchApi<ApiRoom>(`/rooms/${roomId}/`)
}
diff --git a/src/frontend/src/features/rooms/api/joinRoom.ts b/src/frontend/src/features/rooms/api/joinRoom.ts
new file mode 100644
index 00000000..b840a54e
--- /dev/null
+++ b/src/frontend/src/features/rooms/api/joinRoom.ts
@@ -0,0 +1,14 @@
+import { type ApiRoom } from './ApiRoom'
+import { fetchApi } from '@/api/fetchApi'
+
+export type JoinRoomParams = {
+ roomId: string
+ username?: string
+}
+
+export const joinRoom = ({ roomId, username }: JoinRoomParams) => {
+ return fetchApi<ApiRoom>(`/rooms/${roomId}/join/`, {
+ method: 'POST',
+ body: JSON.stringify({ username }),
+ })
+}
diff --git a/src/frontend/src/features/rooms/components/Conference.tsx b/src/frontend/src/features/rooms/components/Conference.tsx
index a66387d7..5e692647 100644
--- a/src/frontend/src/features/rooms/components/Conference.tsx
+++ b/src/frontend/src/features/rooms/components/Conference.tsx
@@ -1,4 +1,4 @@
-import { useEffect, useMemo, useRef, useState } from 'react'
+import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
import { useQuery } from '@tanstack/react-query'
import { useTranslation } from 'react-i18next'
import {
@@ -10,17 +10,16 @@ import {
ConnectionErrorReason,
DisconnectReason,
MediaDeviceFailure,
+ type Room,
type RoomOptions,
VideoPresets,
} from 'livekit-client'
import { getMediaDeviceFailure } from '@/features/rooms/livekit/utils/mediaPermissions'
import { keys } from '@/api/queryKeys'
-import { queryClient } from '@/api/queryClient'
import { Screen } from '@/layout/Screen'
import { QueryAware } from '@/components/QueryAware'
import { ErrorScreen } from '@/components/ErrorScreen'
-import { fetchRoom } from '../api/fetchRoom'
-import type { ApiRoom } from '../api/ApiRoom'
+import { joinRoom } from '../api/joinRoom'
import { useCreateRoom } from '../api/createRoom'
import { InviteDialog } from './InviteDialog'
import { VideoConference } from '../livekit/prefabs/VideoConference'
@@ -32,7 +31,7 @@ import {
captureMediaEvent,
reportError,
} from '@/features/analytics/telemetry'
-import { useConfig } from '@/api/useConfig'
+import { type ApiConfig, useConfig } from '@/api/useConfig'
import { isFireFox } from '@/utils/livekit'
import { useIsMobile } from '@/utils/useIsMobile'
import { navigateTo } from '@/navigation/navigateTo'
@@ -48,6 +47,13 @@ import { resolveAudioOutputDeviceId } from '@/features/rooms/utils/resolveAudioO
import { ConnectionEndReason } from '@/features/rooms/utils/connectionEndReason'
import { createLiveKitRoom } from '@/features/rooms/livekit/utils/reconnectPolicy'
+// Some clients (like DINUM) operate in bandwidth-constrained environments
+// These settings help ensure successful connections in poor network conditions
+const connectOptions = {
+ maxRetries: 5, // Default: 1. Only for unreachable server scenarios
+ peerConnectionTimeout: 60000, // Default: 15s. Extended for slow TURN/TLS negotiation
+}
+
const handleError = (e: Error) => {
const failure = getMediaDeviceFailure(e)
if (failure && failure !== MediaDeviceFailure.Other) return
@@ -66,65 +72,111 @@ const handleError = (e: Error) => {
})
}
+/**
+ * Warm up connection to LiveKit server before joining room
+ * This prefetch helps reduce initial connection latency by establishing
+ * an early HTTP connection to the WebRTC signaling server
+ *
+ * It should cache DNS and TLS keys.
+ */
+const warmUpConnection = async (room: Room, livekit: ApiConfig['livekit']) => {
+ await room.prepareConnection(livekit.url)
+
+ if (isFireFox() && livekit.enable_firefox_proxy_workaround) {
+ try {
+ const wssUrl =
+ livekit.url.replace('https://', 'wss://').replace(/\/$/, '') + '/rtc'
+
+ /**
+ * FIREFOX + PROXY WORKAROUND:
+ *
+ * Issue: On Firefox behind proxy configurations, WebSocket signaling fails to establish.
+ * Symptom: Client receives HTTP 200 instead of expected 101 (Switching Protocols).
+ * Root Cause: Certificate/security issue where the initial request is considered insecure.
+ *
+ * Solution: Pre-establish a WebSocket connection to the signaling server, which fails.
+ * This "primes" the connection, allowing subsequent WebSocket establishments to work correctly.
+ *
+ * Note: This issue is reproducible on LiveKit's demo app.
+ * Reference: livekit-examples/meet/issues/466
+ */
+ const ws = new WebSocket(wssUrl)
+ // 401 unauthorized response is expected
+ ws.onerror = () => ws.readyState <= 1 && ws.close()
+ } catch (e) {
+ console.debug('Firefox WebSocket workaround failed.', e)
+ }
+ }
+}
+
+const getConnectionEndReason = (
+ reason: DisconnectReason | undefined,
+ hasConnected: boolean
+) => {
+ switch (reason) {
+ case DisconnectReason.CLIENT_INITIATED:
+ return undefined
+ case DisconnectReason.DUPLICATE_IDENTITY:
+ case DisconnectReason.PARTICIPANT_REMOVED:
+ case DisconnectReason.ROOM_DELETED:
+ return reason
+ default:
+ // Reconnecting gave up, or the join itself failed
+ return hasConnected
+ ? ConnectionEndReason.Lost
+ : ConnectionEndReason.Failed
+ }
+}
+
export const Conference = ({
roomId,
- initialRoomData,
mode = 'join',
+ onLobbyRequired,
}: {
roomId: string
mode?: 'join' | 'create'
- initialRoomData?: ApiRoom
+ onLobbyRequired: () => void
}) => {
+ const { t } = useTranslation('rooms')
const { data: apiConfig } = useConfig()
-
const { userChoices: userConfig } = usePersistentUserChoices() as {
userChoices: LocalUserChoices
}
-
const { username } = useSnapshot(userStore)
-
- useEffect(() => {
- void captureMediaEvent('visit-room', { slug: roomId })
- }, [roomId])
- const fetchKey = [keys.room, roomId]
-
- const [isConnectionWarmedUp, setIsConnectionWarmedUp] = useState(false)
-
const userPreferencesSnap = useSnapshot(userPreferencesStore)
+ const isMobile = useIsMobile()
- const {
- mutateAsync: createRoom,
- status: createStatus,
- isError: isCreateError,
- } = useCreateRoom({
- onSuccess: (data) => {
- queryClient.setQueryData(fetchKey, data)
- },
- })
+ const [hasJoined, setHasJoined] = useState(false)
+ const [isConnectionWarmedUp, setIsConnectionWarmedUp] = useState(false)
+ const hasAutoMutedRef = useRef(false)
+ const hasConnectedRef = useRef(false)
+ const { mutateAsync: createRoom, isError: isCreateError } = useCreateRoom()
const {
status: fetchStatus,
- isError: isFetchError,
error: fetchError,
- data,
+ data: createRoomData,
} = useQuery({
- queryKey: fetchKey,
+ queryKey: [keys.room, roomId],
staleTime: 6 * 60 * 60 * 1000, // By default, LiveKit access tokens expire 6 hours after generation
- initialData: initialRoomData,
queryFn: () =>
- fetchRoom({
- roomId: roomId as string,
- username: username,
- }).catch((error) => {
- if (error.statusCode == '404') {
- createRoom({ slug: roomId, username })
- }
- // A deleted room can't be recreated, surface the error instead
- if (error.statusCode == '410') throw error
+ joinRoom({ roomId, username }).catch(async (error) => {
+ if (error.statusCode != 404) throw error
+ await createRoom({ slug: roomId })
+ return joinRoom({ roomId, username })
}),
retry: false,
})
+ const isLobbyRequired =
+ !!createRoomData && !createRoomData.livekit && !hasJoined
+ const status =
+ createRoomData?.livekit || hasJoined
+ ? 'success'
+ : isLobbyRequired
+ ? 'pending'
+ : fetchStatus
+
const roomOptions = useMemo((): RoomOptions => {
return {
adaptiveStream: true,
@@ -155,62 +207,11 @@ export const Conference = ({
apiConfig?.livekit.default_video_codec,
])
- const reconnect = apiConfig?.livekit.reconnect
const room = useMemo(
- () => createLiveKitRoom(roomOptions, reconnect),
- [roomOptions, reconnect]
+ () => createLiveKitRoom(roomOptions, apiConfig?.livekit.reconnect),
+ [roomOptions, apiConfig?.livekit.reconnect]
)
- useEffect(() => {
- /**
- * Warm up connection to LiveKit server before joining room
- * This prefetch helps reduce initial connection latency by establishing
- * an early HTTP connection to the WebRTC signaling server
- *
- * It should cache DNS and TLS keys.
- */
- const prepareConnection = async () => {
- if (!apiConfig || isConnectionWarmedUp) return
- await room.prepareConnection(apiConfig.livekit.url)
-
- if (isFireFox() && apiConfig.livekit.enable_firefox_proxy_workaround) {
- try {
- const wssUrl =
- apiConfig.livekit.url
- .replace('https://', 'wss://')
- .replace(/\/$/, '') + '/rtc'
-
- /**
- * FIREFOX + PROXY WORKAROUND:
- *
- * Issue: On Firefox behind proxy configurations, WebSocket signaling fails to establish.
- * Symptom: Client receives HTTP 200 instead of expected 101 (Switching Protocols).
- * Root Cause: Certificate/security issue where the initial request is considered insecure.
- *
- * Solution: Pre-establish a WebSocket connection to the signaling server, which fails.
- * This "primes" the connection, allowing subsequent WebSocket establishments to work correctly.
- *
- * Note: This issue is reproducible on LiveKit's demo app.
- * Reference: livekit-examples/meet/issues/466
- */
- const ws = new WebSocket(wssUrl)
- // 401 unauthorized response is expected
- ws.onerror = () => ws.readyState <= 1 && ws.close()
- } catch (e) {
- console.debug('Firefox WebSocket workaround failed.', e)
- }
- }
-
- setIsConnectionWarmedUp(true)
- }
- prepareConnection()
- }, [room, apiConfig, isConnectionWarmedUp])
-
- const isMobile = useIsMobile()
-
- const hasAutoMutedRef = useRef(false)
- const hasConnectedRef = useRef(false)
-
/*
* Ensure stable WebSocket connection URL. This is critical for legacy browser compatibility
* (Firefox <124, Chrome <125, Edge <125) where HTTPS URLs in WebSocket() constructor
@@ -225,7 +226,61 @@ export const Conference = ({
return livekit_url
}, [apiConfig?.livekit])
- const { t } = useTranslation('rooms')
+ const handleConnected = useCallback(async () => {
+ hasConnectedRef.current = true
+ if (!apiConfig) return
+ if (
+ userPreferencesSnap.is_auto_mute_large_room_enabled &&
+ !hasAutoMutedRef.current &&
+ userConfig.audioEnabled &&
+ room.numParticipants > apiConfig.auto_mute_on_join_threshold
+ ) {
+ hasAutoMutedRef.current = true
+ await room.localParticipant.setMicrophoneEnabled(false)
+ notifyAutoMutedOnJoin()
+ }
+ }, [
+ apiConfig,
+ room,
+ userConfig.audioEnabled,
+ userPreferencesSnap.is_auto_mute_large_room_enabled,
+ ])
+
+ const handleDisconnected = useCallback(
+ (reason?: DisconnectReason) => {
+ navigateTo(
+ 'feedback',
+ {},
+ {
+ state: {
+ reason: getConnectionEndReason(reason, hasConnectedRef.current),
+ room_id: roomId,
+ },
+ }
+ )
+ },
+ [roomId]
+ )
+
+ useEffect(() => {
+ void captureMediaEvent('visit-room', { slug: roomId })
+ }, [roomId])
+
+ useEffect(() => {
+ if (createRoomData?.livekit) setHasJoined(true)
+ }, [createRoomData?.livekit])
+
+ useEffect(() => {
+ if (isLobbyRequired) onLobbyRequired()
+ }, [isLobbyRequired, onLobbyRequired])
+
+ useEffect(() => {
+ if (!apiConfig || isConnectionWarmedUp) return
+ warmUpConnection(room, apiConfig.livekit).then(() =>
+ setIsConnectionWarmedUp(true)
+ )
+ }, [room, apiConfig, isConnectionWarmedUp])
+
if (fetchError?.statusCode == 410) {
return (
<ErrorScreen
@@ -245,20 +300,13 @@ export const Conference = ({
)
}
- // Some clients (like DINUM) operate in bandwidth-constrained environments
- // These settings help ensure successful connections in poor network conditions
- const connectOptions = {
- maxRetries: 5, // Default: 1. Only for unreachable server scenarios
- peerConnectionTimeout: 60000, // Default: 15s. Extended for slow TURN/TLS negotiation
- }
-
return (
- <QueryAware status={isFetchError ? createStatus : fetchStatus}>
+ <QueryAware status={status}>
<Screen header={false} footer={false}>
<LiveKitRoom
room={room}
serverUrl={serverUrl}
- token={data?.livekit?.token}
+ token={createRoomData?.livekit?.token}
connect={isConnectionWarmedUp}
audio={userConfig.audioEnabled}
video={
@@ -273,65 +321,8 @@ export const Conference = ({
backgroundColor: 'primaryDark.50 !important',
})}
onError={handleError}
- onConnected={async () => {
- hasConnectedRef.current = true
- if (!apiConfig) return
- if (
- userPreferencesSnap.is_auto_mute_large_room_enabled &&
- !hasAutoMutedRef.current &&
- userConfig.audioEnabled &&
- room.numParticipants > apiConfig.auto_mute_on_join_threshold
- ) {
- hasAutoMutedRef.current = true
- await room.localParticipant.setMicrophoneEnabled(false)
- notifyAutoMutedOnJoin()
- }
- }}
- onDisconnected={(e) => {
- const metadata = {
- room_id: roomId,
- }
-
- switch (e) {
- case DisconnectReason.CLIENT_INITIATED:
- navigateTo(
- 'feedback',
- {},
- {
- state: { ...metadata },
- }
- )
- return
- case DisconnectReason.DUPLICATE_IDENTITY:
- case DisconnectReason.PARTICIPANT_REMOVED:
- case DisconnectReason.ROOM_DELETED:
- navigateTo(
- 'feedback',
- {},
- {
- state: {
- reason: e,
- ...metadata,
- },
- }
- )
- return
- default:
- // Reconnecting gave up, or the join itself failed
- navigateTo(
- 'feedback',
- {},
- {
- state: {
- reason: hasConnectedRef.current
- ? ConnectionEndReason.Lost
- : ConnectionEndReason.Failed,
- ...metadata,
- },
- }
- )
- }
- }}
+ onConnected={handleConnected}
+ onDisconnected={handleDisconnected}
>
<WatchMediaDeviceErrors />
<VideoConference />
diff --git a/src/frontend/src/features/rooms/components/Lobby.tsx b/src/frontend/src/features/rooms/components/Lobby.tsx
index 9a26c1b2..c844f1d8 100644
--- a/src/frontend/src/features/rooms/components/Lobby.tsx
+++ b/src/frontend/src/features/rooms/components/Lobby.tsx
@@ -1,6 +1,6 @@
-import { useEffect } from 'react'
+import { type ReactNode } from 'react'
import { useTranslation } from 'react-i18next'
-import { useQuery } from '@tanstack/react-query'
+import { useMutation } from '@tanstack/react-query'
import { useSnapshot } from 'valtio'
import { css } from '@/styled-system/css'
import { VStack } from '@/styled-system/jsx'
@@ -10,15 +10,40 @@ import { Form, Text } from '@/primitives'
import { Spinner } from '@/primitives/Spinner'
import { keys } from '@/api/queryKeys'
import { queryClient } from '@/api/queryClient'
+import type { ApiError } from '@/api/ApiError'
import { useLoginHint } from '@/hooks/useLoginHint'
import { useUser } from '@/features/auth/api/useUser'
import { useConfig } from '@/api/useConfig'
import { saveUsername, userStore } from '@/stores/user'
-import { fetchRoom } from '../api/fetchRoom'
-import { ApiAccessLevel } from '../api/ApiRoom'
-import { ApiLobbyStatus, type ApiRequestEntry } from '../api/requestEntry'
+import { joinRoom, type JoinRoomParams } from '../api/joinRoom'
+import { ApiAccessLevel, type ApiRoom } from '../api/ApiRoom'
+import { ApiLobbyStatus } from '../api/requestEntry'
import { useLobby } from '../hooks/useLobby'
+const LobbyMessage = ({
+ title,
+ body,
+ children,
+}: {
+ title: string
+ body: string
+ children?: ReactNode
+}) => (
+ <VStack alignItems="center" textAlign="center">
+ <H lvl={1} margin={false} centered>
+ {title}
+ </H>
+ <Text
+ as="p"
+ variant="note"
+ className={children ? css({ marginBottom: '1.5rem' }) : undefined}
+ >
+ {body}
+ </Text>
+ {children}
+ </VStack>
+)
+
export const Lobby = ({
roomId,
enterRoom,
@@ -27,124 +52,97 @@ export const Lobby = ({
enterRoom: () => void
}) => {
const { t } = useTranslation('rooms', { keyPrefix: 'join' })
-
const { data: configData } = useConfig()
const { isLoggedIn, user } = useUser()
const { username } = useSnapshot(userStore)
+ const { openLoginHint } = useLoginHint()
+
+ const displayName = username || user?.full_name
- // Room data strategy:
- // 1. Initial fetch is performed to check access and get LiveKit configuration
- // 2. Data remains valid for 6 hours to avoid unnecessary refetches
- // 3. State is manually updated via queryClient when a waiting participant is accepted
- // 4. No automatic refetching or revalidation occurs during this period
+ // Join strategy:
+ // 1. Submitting the form asks to join the room, which checks access
+ // 2. The response is written to the [keys.room] cache entry, which
+ // Conference reuses without refetching. It holds the LiveKit credentials
+ // when the user may bypass the lobby
+ // 3. Otherwise the user waits in the lobby, and the credentials returned
+ // once accepted are added to it
const {
+ mutate: join,
data: roomData,
error,
isError,
- refetch: refetchRoom,
- } = useQuery({
- queryKey: [keys.room, roomId],
- queryFn: () => fetchRoom({ roomId, username: username || user?.full_name }),
- staleTime: 6 * 60 * 60 * 1000, // By default, LiveKit access tokens expire 6 hours after generation
- retry: false,
- enabled: false,
- })
-
- useEffect(() => {
- if (isError && error?.statusCode == 404) {
+ } = useMutation<ApiRoom, ApiError, JoinRoomParams>({
+ mutationFn: joinRoom,
+ onSuccess: (room) => {
+ queryClient.setQueryData([keys.room, roomId], room)
+ },
+ onError: ({ statusCode }) => {
// The room component will handle the room creation if the user is authenticated
- enterRoom()
- }
- }, [isError, error, enterRoom])
-
- const handleAccepted = (response: ApiRequestEntry) => {
- queryClient.setQueryData([keys.room, roomId], {
- ...roomData,
- livekit: response.livekit,
- })
- enterRoom()
- }
+ if (statusCode == 404) enterRoom()
+ },
+ })
const { status, startWaiting } = useLobby({
roomId,
- username: username || user?.full_name || 'anonymous',
- onAccepted: handleAccepted,
+ username: displayName || 'anonymous',
+ onAccepted: (response) => {
+ queryClient.setQueryData([keys.room, roomId], {
+ ...roomData,
+ livekit: response.livekit,
+ })
+ enterRoom()
+ },
})
- const { openLoginHint } = useLoginHint()
-
- const handleSubmit = async () => {
- const { data, error } = await refetchRoom()
-
- if (error?.statusCode == 410) return
+ const isRoomDeleted = isError && error?.statusCode == 410
+ const lobbyStatus = isRoomDeleted ? ApiLobbyStatus.DELETED : status
- if (!data?.livekit) {
- // Display a message to inform the user that by logging in, they won't have to wait for room entry approval.
- if (data?.access_level == ApiAccessLevel.TRUSTED) {
- openLoginHint()
+ const handleSubmit = () => {
+ join(
+ { roomId, username: displayName || undefined },
+ {
+ onSuccess: (data) => {
+ if (data.livekit) {
+ enterRoom()
+ return
+ }
+ if (data.access_level == ApiAccessLevel.TRUSTED) {
+ openLoginHint()
+ }
+ startWaiting()
+ },
+ onError: ({ statusCode }) => {
+ // 404 enters the room and creates it
+ // 410 shows the deleted room screen
+ // Any other error falls back to the lobby
+ if (statusCode != 404 && statusCode != 410) startWaiting()
+ },
}
- startWaiting()
- return
- }
-
- enterRoom()
+ )
}
- const isRoomDeleted = isError && error?.statusCode == 410
- const lobbyStatus = isRoomDeleted ? ApiLobbyStatus.DELETED : status
-
switch (lobbyStatus) {
case ApiLobbyStatus.DELETED:
return (
- <VStack alignItems="center" textAlign="center">
- <H lvl={1} margin={false} centered>
- {t('deleted.title')}
- </H>
- <Text as="p" variant="note">
- {t('deleted.body')}
- </Text>
- </VStack>
+ <LobbyMessage title={t('deleted.title')} body={t('deleted.body')} />
)
case ApiLobbyStatus.TIMEOUT:
return (
- <VStack alignItems="center" textAlign="center">
- <H lvl={1} margin={false} centered>
- {t('timeoutInvite.title')}
- </H>
- <Text as="p" variant="note">
- {t('timeoutInvite.body')}
- </Text>
- </VStack>
+ <LobbyMessage
+ title={t('timeoutInvite.title')}
+ body={t('timeoutInvite.body')}
+ />
)
case ApiLobbyStatus.DENIED:
- return (
- <VStack alignItems="center" textAlign="center">
- <H lvl={1} margin={false} centered>
- {t('denied.title')}
- </H>
- <Text as="p" variant="note">
- {t('denied.body')}
- </Text>
- </VStack>
- )
+ return <LobbyMessage title={t('denied.title')} body={t('denied.body')} />
case ApiLobbyStatus.WAITING:
return (
- <VStack alignItems="center" textAlign="center">
- <H lvl={1} margin={false} centered>
- {t('waiting.title')}
- </H>
- <Text
- as="p"
- variant="note"
- className={css({ marginBottom: '1.5rem' })}
- >
- {t('waiting.body')}
- </Text>
+ <LobbyMessage title={t('waiting.title')} body={t('waiting.body')}>
<Spinner />
- </VStack>
+ </LobbyMessage>
)
default:
@@ -168,7 +166,7 @@ export const Lobby = ({
label={t('usernameLabel')}
aria-label={t('usernameLabel')}
id="input-name"
- defaultValue={username || user?.full_name}
+ defaultValue={displayName}
validate={(value) => !value && t('errors.usernameEmpty')}
wrapperProps={{
noMargin: true,
diff --git a/src/frontend/src/features/rooms/livekit/components/Admin.tsx b/src/frontend/src/features/rooms/livekit/components/Admin.tsx
index 7b4b5b2c..fcfdaf0d 100644
--- a/src/frontend/src/features/rooms/livekit/components/Admin.tsx
+++ b/src/frontend/src/features/rooms/livekit/components/Admin.tsx
@@ -3,13 +3,11 @@ import { css } from '@/styled-system/css'
import { Separator as RACSeparator } from 'react-aria-components'
import { useTranslation } from 'react-i18next'
import { usePatchRoom } from '@/features/rooms/api/patchRoom'
-import { fetchRoom } from '@/features/rooms/api/fetchRoom'
import { ApiAccessLevel } from '@/features/rooms/api/ApiRoom'
-import { keys } from '@/api/queryKeys'
-import { useQuery } from '@tanstack/react-query'
import { useParams } from 'wouter'
import { usePublishSourcesManager } from '../hooks/usePublishSourcesManager'
import { usePermissionsManager } from '../hooks/usePermissionsManager'
+import { useRoomData } from '../hooks/useRoomData'
import { useEffect } from 'react'
import { closeSidePanel } from '@/stores/layout'
import { useIsAdminOrOwner } from '../hooks/useIsAdminOrOwner'
@@ -34,12 +32,10 @@ export const Admin = () => {
}
}, [isAdminOrOwner])
- const { data: readOnlyData } = useQuery({
- queryKey: [keys.room, roomId],
- queryFn: () => fetchRoom({ roomId }),
- retry: false,
- enabled: false,
- })
+ // Read the cached room only: an observer with its own queryFn could serve
+ // the refetch that follows a setting change with a GET, which returns no
+ // LiveKit credentials
+ const readOnlyData = useRoomData()
const {
toggleMicrophone,
diff --git a/src/frontend/src/features/rooms/routes/Room.tsx b/src/frontend/src/features/rooms/routes/Room.tsx
index ae8ba164..f0097aaa 100644
--- a/src/frontend/src/features/rooms/routes/Room.tsx
+++ b/src/frontend/src/features/rooms/routes/Room.tsx
@@ -32,10 +32,12 @@ const BaseRoom = ({ children }: { children: ReactNode }) => {
const Room = () => {
const { isLoggedIn } = useUser()
const [hasSubmittedEntry, setHasSubmittedEntry] = useState(false)
+ // Set by the conference when the user turns out to have to go through the
+ // lobby, even when the join screen was skipped
+ const [isLobbyRequired, setIsLobbyRequired] = useState(false)
const { roomId } = useParams()
const [location, setLocation] = useLocation()
- const initialRoomData = history.state?.initialRoomData
const mode = isLoggedIn && history.state?.create ? 'create' : 'join'
const skipJoinScreen = isLoggedIn && mode === 'create'
@@ -75,10 +77,16 @@ const Room = () => {
return <ErrorScreen />
}
- if (!hasSubmittedEntry && !skipJoinScreen) {
+ if (isLobbyRequired || (!hasSubmittedEntry && !skipJoinScreen)) {
return (
<BaseRoom>
- <Join enterRoom={() => setHasSubmittedEntry(true)} roomId={roomId} />
+ <Join
+ enterRoom={() => {
+ setIsLobbyRequired(false)
+ setHasSubmittedEntry(true)
+ }}
+ roomId={roomId}
+ />
</BaseRoom>
)
}
@@ -86,9 +94,10 @@ const Room = () => {
return (
<BaseRoom>
<Conference
- initialRoomData={initialRoomData}
+ key={roomId}
roomId={roomId}
mode={mode}
+ onLobbyRequired={() => setIsLobbyRequired(true)}
/>
</BaseRoom>
)