1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

Disable refetch on window refocus for search suggestions

This commit is contained in:
viown 2025-03-06 18:58:15 +03:00
parent 2776e660fa
commit 533ea7dbb9

View file

@ -7,14 +7,11 @@ import { useQuery } from '@tanstack/react-query';
import { useApi } from 'hooks/useApi'; import { useApi } from 'hooks/useApi';
const fetchGetItems = async ( const fetchGetItems = async (
api?: Api, api: Api,
userId?: string, userId: string,
parentId?: string, parentId?: string,
options?: AxiosRequestConfig options?: AxiosRequestConfig
) => { ) => {
if (!api) throw new Error('No API instance available');
if (!userId) throw new Error('No User ID provided');
const response = await getItemsApi(api).getItems( const response = await getItemsApi(api).getItems(
{ {
userId: userId, userId: userId,
@ -43,7 +40,8 @@ export const useSearchSuggestions = (parentId?: string) => {
return useQuery({ return useQuery({
queryKey: ['SearchSuggestions', { parentId }], queryKey: ['SearchSuggestions', { parentId }],
queryFn: ({ signal }) => queryFn: ({ signal }) =>
fetchGetItems(api, userId, parentId, { signal }), fetchGetItems(api!, userId!, parentId, { signal }),
refetchOnWindowFocus: false,
enabled: !!api && !!userId enabled: !!api && !!userId
}); });
}; };