🐛(frontend) avoid unnecessary refetches of room's data
LiveKit access tokens are valid for 6 hours after generation. Without a `staleTime` set, room data becomes stale immediately (0 milliseconds), causing unnecessary refetches, particularly when users switch focus back to the call window. This issue led to an excessive number of "get room" events, as observed in the analytics. For example, during a meeting, if a user switches tabs and then returns, the room data would be refetched despite the access token still being valid. By adding a `staleTime` aligned with the token's validity, we avoid unnecessary network requests.
This commit is contained in:
@@ -49,6 +49,7 @@ export const Conference = ({
|
||||
data,
|
||||
} = useQuery({
|
||||
queryKey: fetchKey,
|
||||
staleTime: 6 * 60 * 60 * 1000, // By default, LiveKit access tokens expire 6 hours after generation
|
||||
enabled: !initialRoomData,
|
||||
initialData: initialRoomData,
|
||||
queryFn: () =>
|
||||
|
||||
Reference in New Issue
Block a user