Skip to content

Commit

Permalink
️♻️(frontend) make the Conference component not know about routing
Browse files Browse the repository at this point in the history
Makes more sense that way: only the Room _route_ knows about route
params, not the internal component used.
  • Loading branch information
manuhabitela committed Jul 21, 2024
1 parent e04b8d0 commit 668b927
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/frontend/src/features/rooms/components/Conference.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { useParams } from 'wouter'
import { useQuery } from '@tanstack/react-query'
import {
LiveKitRoom,
Expand All @@ -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: () =>
Expand Down
8 changes: 7 additions & 1 deletion src/frontend/src/features/rooms/routes/Room.tsx
Original file line number Diff line number Diff line change
@@ -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} />
)}
Expand Down

0 comments on commit 668b927

Please sign in to comment.