🐛(frontend) pass participant's name while creating a room
Fixed an issue where users' chosen usernames were not being included when creating a room.
This commit is contained in:
committed by
aleb_the_flash
parent
378cc3a651
commit
66350b8fb5
@@ -9,11 +9,16 @@ import { generateRoomId } from '@/features/rooms'
|
|||||||
import { authUrl, useUser, UserAware } from '@/features/auth'
|
import { authUrl, useUser, UserAware } from '@/features/auth'
|
||||||
import { JoinMeetingDialog } from '../components/JoinMeetingDialog'
|
import { JoinMeetingDialog } from '../components/JoinMeetingDialog'
|
||||||
import { useCreateRoom } from '@/features/rooms'
|
import { useCreateRoom } from '@/features/rooms'
|
||||||
|
import { usePersistentUserChoices } from '@livekit/components-react'
|
||||||
|
|
||||||
export const Home = () => {
|
export const Home = () => {
|
||||||
const { t } = useTranslation('home')
|
const { t } = useTranslation('home')
|
||||||
const { isLoggedIn } = useUser()
|
const { isLoggedIn } = useUser()
|
||||||
|
|
||||||
|
const {
|
||||||
|
userChoices: { username },
|
||||||
|
} = usePersistentUserChoices()
|
||||||
|
|
||||||
const { mutateAsync: createRoom } = useCreateRoom({
|
const { mutateAsync: createRoom } = useCreateRoom({
|
||||||
onSuccess: (data) => {
|
onSuccess: (data) => {
|
||||||
navigateTo('room', data.slug, {
|
navigateTo('room', data.slug, {
|
||||||
@@ -44,7 +49,7 @@ export const Home = () => {
|
|||||||
isLoggedIn
|
isLoggedIn
|
||||||
? async () => {
|
? async () => {
|
||||||
const slug = generateRoomId()
|
const slug = generateRoomId()
|
||||||
await createRoom({ slug })
|
await createRoom({ slug, username })
|
||||||
}
|
}
|
||||||
: undefined
|
: undefined
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,10 +5,14 @@ import { ApiRoom } from './ApiRoom'
|
|||||||
|
|
||||||
export interface CreateRoomParams {
|
export interface CreateRoomParams {
|
||||||
slug: string
|
slug: string
|
||||||
|
username?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
const createRoom = ({ slug }: CreateRoomParams): Promise<ApiRoom> => {
|
const createRoom = ({
|
||||||
return fetchApi(`rooms/`, {
|
slug,
|
||||||
|
username = '',
|
||||||
|
}: CreateRoomParams): Promise<ApiRoom> => {
|
||||||
|
return fetchApi(`rooms/?username=${encodeURIComponent(username)}`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
name: slug,
|
name: slug,
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ export const Conference = ({
|
|||||||
username: userConfig.username,
|
username: userConfig.username,
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
if (error.statusCode == '404') {
|
if (error.statusCode == '404') {
|
||||||
createRoom({ slug: roomId })
|
createRoom({ slug: roomId, username: userConfig.username })
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
retry: false,
|
retry: false,
|
||||||
|
|||||||
Reference in New Issue
Block a user