🐛(frontend) fix useRoomData when a participant's name has changed

The participant's name in the query key prevented proper cache invalidation
when renamed. Since name changes don't affect query data, removed this
dependency.
This commit is contained in:
lebaudantoine
2025-02-11 17:57:09 +01:00
committed by aleb_the_flash
parent 87baca247b
commit fc36ae8b49
2 changed files with 3 additions and 4 deletions

View File

@@ -32,7 +32,7 @@ export const Conference = ({
useEffect(() => {
posthog.capture('visit-room', { slug: roomId })
}, [roomId])
const fetchKey = [keys.room, roomId, userConfig.username]
const fetchKey = [keys.room, roomId]
const {
mutateAsync: createRoom,
@@ -49,6 +49,7 @@ export const Conference = ({
isError: isFetchError,
data,
} = useQuery({
/* eslint-disable @tanstack/query/exhaustive-deps */
queryKey: fetchKey,
staleTime: 6 * 60 * 60 * 1000, // By default, LiveKit access tokens expire 6 hours after generation
initialData: initialRoomData,

View File

@@ -1,12 +1,10 @@
import { ApiRoom } from '@/features/rooms/api/ApiRoom'
import { useRoomContext } from '@livekit/components-react'
import { useParams } from 'wouter'
import { keys } from '@/api/queryKeys'
import { queryClient } from '@/api/queryClient'
export const useRoomData = (): ApiRoom | undefined => {
const room = useRoomContext()
const { roomId } = useParams()
const queryKey = [keys.room, roomId, room.localParticipant.name]
const queryKey = [keys.room, roomId]
return queryClient.getQueryData<ApiRoom>(queryKey)
}