wip add useUsernameParam to allow passing username through query params

This commit is contained in:
lebaudantoine
2025-06-02 19:02:55 +02:00
parent 69199a7ede
commit a3ab440ad3
2 changed files with 11 additions and 1 deletions
@@ -17,6 +17,7 @@ import posthog from 'posthog-js'
import { css } from '@/styled-system/css'
import { LocalUserChoices } from '../routes/Room'
import { BackgroundProcessorFactory } from '../livekit/components/blur'
import { useUsernameParam } from '@/features/rooms/hooks/useUsernameParam.ts'
export const Conference = ({
roomId,
@@ -29,6 +30,8 @@ export const Conference = ({
mode?: 'join' | 'create'
initialRoomData?: ApiRoom
}) => {
const username = useUsernameParam()
useEffect(() => {
posthog.capture('visit-room', { slug: roomId })
}, [roomId])
@@ -56,7 +59,7 @@ export const Conference = ({
queryFn: () =>
fetchRoom({
roomId: roomId as string,
username: userConfig.username,
username: username != null ? username : userConfig.username,
}).catch((error) => {
if (error.statusCode == '404') {
createRoom({ slug: roomId, username: userConfig.username })
@@ -0,0 +1,7 @@
import { useSearch } from 'wouter'
export const useUsernameParam = () => {
const search = useSearch()
const params = new URLSearchParams(search)
return params.get('username')
}