happy now?
Some checks failed
Deploy SSR / deploy (push) Failing after 31s

This commit is contained in:
Lee 2024-09-13 16:46:29 +01:00
parent dd3b7256b0
commit 709d51b00e
3 changed files with 23 additions and 18 deletions

View File

@ -0,0 +1,19 @@
import ScoreSaberPlayer from "@/common/data-fetcher/types/scoresaber/scoresaber-player";
import { scoresaberFetcher } from "@/common/data-fetcher/impl/scoresaber";
import { ScoreSort } from "@/common/data-fetcher/sort";
export const leaderboards = {
ScoreSaber: {
capabilities: {
search: true,
},
queries: {
lookupScores: (player: ScoreSaberPlayer, sort: ScoreSort, page: number) =>
scoresaberFetcher.lookupPlayerScores({
playerId: player.id,
sort: sort,
page: page,
}),
},
},
};

View File

@ -14,6 +14,7 @@ import Card from "../card";
import Pagination from "../input/pagination";
import { Button } from "../ui/button";
import Score from "./score/score";
import { leaderboards } from "@/common/leaderboards";
type Props = {
initialScoreData?: ScoreSaberPlayerScoresPage;
@ -34,22 +35,6 @@ type PageState = {
sort: ScoreSort;
};
const leaderboards = {
ScoreSaber: {
capabilities: {
search: true,
},
queries: {
lookupScores: (player: ScoreSaberPlayer, pageState: PageState) =>
scoresaberFetcher.lookupPlayerScores({
playerId: player.id,
sort: ScoreSort.top,
page: 1,
}),
},
},
};
const scoreSort = [
{
name: "Top",
@ -114,7 +99,8 @@ export default function PlayerScores({
refetch,
} = useQuery({
queryKey: ["playerScores", player.id, leaderboard, pageState],
queryFn: () => leaderboard.queries.lookupScores(player, pageState),
queryFn: () =>
leaderboard.queries.lookupScores(player, pageState.sort, pageState.page),
staleTime: 30 * 1000, // Cache data for 30 seconds
});

View File

@ -5,7 +5,7 @@ import { ClassValue } from "clsx";
type Badge = {
name: string;
color?: ClassValue;
color?: string;
create: (player: ScoreSaberPlayer) => string | React.ReactNode | undefined;
};