add stale time to score data
All checks were successful
Deploy SSR / deploy (push) Successful in 1m8s

This commit is contained in:
Lee 2024-09-12 11:38:19 +01:00
parent f0dfbe78ea
commit 763de454e7
2 changed files with 13 additions and 1 deletions

@ -12,13 +12,24 @@ import {
} from "../ui/pagination"; } from "../ui/pagination";
type PaginationItemWrapperProps = { type PaginationItemWrapperProps = {
/**
* Whether a page is currently loading.
*/
isLoadingPage: boolean; isLoadingPage: boolean;
/**
* The children to render.
*/
children: React.ReactNode; children: React.ReactNode;
}; };
function PaginationItemWrapper({ isLoadingPage, children }: PaginationItemWrapperProps) { function PaginationItemWrapper({ isLoadingPage, children }: PaginationItemWrapperProps) {
return ( return (
<PaginationItem className={clsx(isLoadingPage ? "cursor-not-allowed" : "cursor-pointer")}> <PaginationItem
className={clsx(isLoadingPage ? "cursor-not-allowed" : "cursor-pointer")}
aria-disabled={isLoadingPage}
tabIndex={isLoadingPage ? -1 : undefined}
>
{children} {children}
</PaginationItem> </PaginationItem>
); );

@ -28,6 +28,7 @@ export default function PlayerScores({ player, sort, page }: Props) {
const { data, isError, isLoading, refetch } = useQuery({ const { data, isError, isLoading, refetch } = useQuery({
queryKey: ["playerScores", player.id, currentSort, currentPage], queryKey: ["playerScores", player.id, currentSort, currentPage],
queryFn: () => scoresaberFetcher.lookupPlayerScores(player.id, currentSort, currentPage), queryFn: () => scoresaberFetcher.lookupPlayerScores(player.id, currentSort, currentPage),
staleTime: 30 * 1000, // Data will be cached for 30 seconds
}); });
useEffect(() => { useEffect(() => {