mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
fix: disable prefetches for audits table (#11040)
This commit is contained in:
@@ -19,5 +19,6 @@ export function paginatedAudits(
|
||||
q: payload,
|
||||
});
|
||||
},
|
||||
prefetch: false,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -66,6 +66,12 @@ export type UsePaginatedQueryOptions<
|
||||
* closest valid page.
|
||||
*/
|
||||
onInvalidPageChange?: (params: InvalidPageParams) => void;
|
||||
|
||||
/**
|
||||
* Defaults to true. Allows you to disable prefetches for pages where making
|
||||
* a request is very expensive.
|
||||
*/
|
||||
prefetch?: boolean;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -98,6 +104,7 @@ export function usePaginatedQuery<
|
||||
onInvalidPageChange,
|
||||
searchParams: outerSearchParams,
|
||||
queryFn: outerQueryFn,
|
||||
prefetch = true,
|
||||
...extraOptions
|
||||
} = options;
|
||||
|
||||
@@ -148,7 +155,12 @@ export function usePaginatedQuery<
|
||||
|
||||
const queryClient = useQueryClient();
|
||||
const prefetchPage = useEffectEvent((newPage: number) => {
|
||||
if (!prefetch) {
|
||||
return;
|
||||
}
|
||||
|
||||
const options = getQueryOptionsFromPage(newPage);
|
||||
|
||||
return queryClient.prefetchQuery(options);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user