Backport pull request #7541 from jellyfin-web/release-10.11.z
Fix random sort items refetching Original-merge: 67a0dcce43e057350124222b2251fed27626ed1d Merged-by: thornbill <thornbill@users.noreply.github.com> Backported-by: thornbill <thornbill@users.noreply.github.com>
This commit is contained in:
@@ -54,6 +54,8 @@ const fetchGetItems = async (
|
|||||||
|
|
||||||
export const useGetItems = (parametersOptions: ItemsApiGetItemsRequest) => {
|
export const useGetItems = (parametersOptions: ItemsApiGetItemsRequest) => {
|
||||||
const currentApi = useApi();
|
const currentApi = useApi();
|
||||||
|
const isRandom = Boolean(parametersOptions.sortBy?.includes(ItemSortBy.Random));
|
||||||
|
|
||||||
return useQuery({
|
return useQuery({
|
||||||
queryKey: [
|
queryKey: [
|
||||||
'Items',
|
'Items',
|
||||||
@@ -63,7 +65,9 @@ export const useGetItems = (parametersOptions: ItemsApiGetItemsRequest) => {
|
|||||||
],
|
],
|
||||||
queryFn: ({ signal }) =>
|
queryFn: ({ signal }) =>
|
||||||
fetchGetItems(currentApi, parametersOptions, { signal }),
|
fetchGetItems(currentApi, parametersOptions, { signal }),
|
||||||
gcTime: parametersOptions.sortBy?.includes(ItemSortBy.Random) ? 0 : undefined,
|
gcTime: isRandom ? Infinity : undefined,
|
||||||
|
refetchOnMount: isRandom ? false : undefined,
|
||||||
|
refetchOnWindowFocus: isRandom ? false : undefined,
|
||||||
enabled: !!currentApi.api && !!currentApi.user?.Id
|
enabled: !!currentApi.api && !!currentApi.user?.Id
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user