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:
parent
2776e660fa
commit
533ea7dbb9
1 changed files with 4 additions and 6 deletions
|
@ -7,14 +7,11 @@ import { useQuery } from '@tanstack/react-query';
|
|||
import { useApi } from 'hooks/useApi';
|
||||
|
||||
const fetchGetItems = async (
|
||||
api?: Api,
|
||||
userId?: string,
|
||||
api: Api,
|
||||
userId: string,
|
||||
parentId?: string,
|
||||
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(
|
||||
{
|
||||
userId: userId,
|
||||
|
@ -43,7 +40,8 @@ export const useSearchSuggestions = (parentId?: string) => {
|
|||
return useQuery({
|
||||
queryKey: ['SearchSuggestions', { parentId }],
|
||||
queryFn: ({ signal }) =>
|
||||
fetchGetItems(api, userId, parentId, { signal }),
|
||||
fetchGetItems(api!, userId!, parentId, { signal }),
|
||||
refetchOnWindowFocus: false,
|
||||
enabled: !!api && !!userId
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue