♻️(frontend) make the Conference component not know about routing

Makes more sense that way: only the Room _route_ knows about route
params, not the internal component used.
This commit is contained in:
Emmanuel Pelletier
2024-07-21 17:41:48 +02:00
parent e04b8d081f
commit faff1c1228
2 changed files with 9 additions and 3 deletions

View File

@@ -1,4 +1,3 @@
import { useParams } from 'wouter'
import { useQuery } from '@tanstack/react-query'
import {
LiveKitRoom,
@@ -11,11 +10,12 @@ import { navigateToHome } from '@/features/home'
import { fetchRoom } from '../api/fetchRoom'
export const Conference = ({
roomId,
userConfig,
}: {
roomId: string
userConfig: LocalUserChoices
}) => {
const { roomId } = useParams()
const { status, data } = useQuery({
queryKey: [keys.room, roomId, userConfig.username],
queryFn: () =>

View File

@@ -1,15 +1,21 @@
import { type LocalUserChoices } from '@livekit/components-react'
import { useState } from 'react'
import { useParams } from 'wouter'
import { Conference } from '../components/Conference'
import { Join } from '../components/Join'
import { Screen } from '@/layout/Screen'
import { ErrorScreen } from '@/layout/ErrorScreen'
export const Room = () => {
const [userConfig, setUserConfig] = useState<LocalUserChoices | null>(null)
const { roomId } = useParams()
if (!roomId) {
return <ErrorScreen />
}
return (
<Screen>
{userConfig ? (
<Conference userConfig={userConfig} />
<Conference roomId={roomId} userConfig={userConfig} />
) : (
<Join onSubmit={setUserConfig} />
)}