️♻️(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:
@@ -1,4 +1,3 @@
|
|||||||
import { useParams } from 'wouter'
|
|
||||||
import { useQuery } from '@tanstack/react-query'
|
import { useQuery } from '@tanstack/react-query'
|
||||||
import {
|
import {
|
||||||
LiveKitRoom,
|
LiveKitRoom,
|
||||||
@@ -11,11 +10,12 @@ import { navigateToHome } from '@/features/home'
|
|||||||
import { fetchRoom } from '../api/fetchRoom'
|
import { fetchRoom } from '../api/fetchRoom'
|
||||||
|
|
||||||
export const Conference = ({
|
export const Conference = ({
|
||||||
|
roomId,
|
||||||
userConfig,
|
userConfig,
|
||||||
}: {
|
}: {
|
||||||
|
roomId: string
|
||||||
userConfig: LocalUserChoices
|
userConfig: LocalUserChoices
|
||||||
}) => {
|
}) => {
|
||||||
const { roomId } = useParams()
|
|
||||||
const { status, data } = useQuery({
|
const { status, data } = useQuery({
|
||||||
queryKey: [keys.room, roomId, userConfig.username],
|
queryKey: [keys.room, roomId, userConfig.username],
|
||||||
queryFn: () =>
|
queryFn: () =>
|
||||||
|
|||||||
@@ -1,15 +1,21 @@
|
|||||||
import { type LocalUserChoices } from '@livekit/components-react'
|
import { type LocalUserChoices } from '@livekit/components-react'
|
||||||
import { useState } from 'react'
|
import { useState } from 'react'
|
||||||
|
import { useParams } from 'wouter'
|
||||||
import { Conference } from '../components/Conference'
|
import { Conference } from '../components/Conference'
|
||||||
import { Join } from '../components/Join'
|
import { Join } from '../components/Join'
|
||||||
import { Screen } from '@/layout/Screen'
|
import { Screen } from '@/layout/Screen'
|
||||||
|
import { ErrorScreen } from '@/layout/ErrorScreen'
|
||||||
|
|
||||||
export const Room = () => {
|
export const Room = () => {
|
||||||
const [userConfig, setUserConfig] = useState<LocalUserChoices | null>(null)
|
const [userConfig, setUserConfig] = useState<LocalUserChoices | null>(null)
|
||||||
|
const { roomId } = useParams()
|
||||||
|
if (!roomId) {
|
||||||
|
return <ErrorScreen />
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<Screen>
|
<Screen>
|
||||||
{userConfig ? (
|
{userConfig ? (
|
||||||
<Conference userConfig={userConfig} />
|
<Conference roomId={roomId} userConfig={userConfig} />
|
||||||
) : (
|
) : (
|
||||||
<Join onSubmit={setUserConfig} />
|
<Join onSubmit={setUserConfig} />
|
||||||
)}
|
)}
|
||||||
|
|||||||
Reference in New Issue
Block a user