This commit is contained in:
parent
11a8ee56cc
commit
1733822bab
@ -1,24 +0,0 @@
|
|||||||
import { scoresaberService } from "@/common/service/impl/scoresaber";
|
|
||||||
import { ScoreSort } from "@/common/service/score-sort";
|
|
||||||
import ScoreSaberPlayer from "@/common/model/player/impl/scoresaber-player";
|
|
||||||
|
|
||||||
export const leaderboards = {
|
|
||||||
ScoreSaber: {
|
|
||||||
capabilities: {
|
|
||||||
search: true,
|
|
||||||
},
|
|
||||||
queries: {
|
|
||||||
lookupScores: (player: ScoreSaberPlayer, sort: ScoreSort, page: number) =>
|
|
||||||
scoresaberService.lookupPlayerScores({
|
|
||||||
playerId: player.id,
|
|
||||||
sort: sort,
|
|
||||||
page: page,
|
|
||||||
}),
|
|
||||||
|
|
||||||
lookupGlobalPlayers: (page: number) =>
|
|
||||||
scoresaberService.lookupPlayers(page),
|
|
||||||
lookupGlobalPlayersByCountry: (page: number, country: string) =>
|
|
||||||
scoresaberService.lookupPlayersByCountry(page, country),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
@ -15,7 +15,7 @@ import { Input } from "../ui/input";
|
|||||||
import { ScrollArea } from "../ui/scroll-area";
|
import { ScrollArea } from "../ui/scroll-area";
|
||||||
|
|
||||||
const formSchema = z.object({
|
const formSchema = z.object({
|
||||||
username: z.string().min(2).max(50),
|
username: z.string().min(3).max(50),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default function SearchPlayer() {
|
export default function SearchPlayer() {
|
||||||
|
@ -9,11 +9,11 @@ import { useCallback, useEffect, useState } from "react";
|
|||||||
import Card from "../card";
|
import Card from "../card";
|
||||||
import Pagination from "../input/pagination";
|
import Pagination from "../input/pagination";
|
||||||
import { Button } from "../ui/button";
|
import { Button } from "../ui/button";
|
||||||
import { leaderboards } from "@/common/leaderboards";
|
|
||||||
import { ScoreSort } from "@/common/service/score-sort";
|
import { ScoreSort } from "@/common/service/score-sort";
|
||||||
import ScoreSaberPlayerScoresPageToken from "@/common/model/token/scoresaber/score-saber-player-scores-page-token";
|
import ScoreSaberPlayerScoresPageToken from "@/common/model/token/scoresaber/score-saber-player-scores-page-token";
|
||||||
import Score from "@/components/score/score";
|
import Score from "@/components/score/score";
|
||||||
import ScoreSaberPlayer from "@/common/model/player/impl/scoresaber-player";
|
import ScoreSaberPlayer from "@/common/model/player/impl/scoresaber-player";
|
||||||
|
import { scoresaberService } from "@/common/service/impl/scoresaber";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
initialScoreData?: ScoreSaberPlayerScoresPageToken;
|
initialScoreData?: ScoreSaberPlayerScoresPageToken;
|
||||||
@ -77,7 +77,6 @@ export default function PlayerScores({
|
|||||||
sort,
|
sort,
|
||||||
page,
|
page,
|
||||||
}: Props) {
|
}: Props) {
|
||||||
const leaderboard = leaderboards.ScoreSaber;
|
|
||||||
const { width } = useWindowDimensions();
|
const { width } = useWindowDimensions();
|
||||||
const controls = useAnimation();
|
const controls = useAnimation();
|
||||||
|
|
||||||
@ -97,9 +96,13 @@ export default function PlayerScores({
|
|||||||
isLoading,
|
isLoading,
|
||||||
refetch,
|
refetch,
|
||||||
} = useQuery({
|
} = useQuery({
|
||||||
queryKey: ["playerScores", player.id, leaderboard, pageState],
|
queryKey: ["playerScores", player.id, pageState],
|
||||||
queryFn: () =>
|
queryFn: () =>
|
||||||
leaderboard.queries.lookupScores(player, pageState.sort, pageState.page),
|
scoresaberService.lookupPlayerScores({
|
||||||
|
playerId: player.id,
|
||||||
|
sort: pageState.sort,
|
||||||
|
page: pageState.page,
|
||||||
|
}),
|
||||||
staleTime: 30 * 1000, // Cache data for 30 seconds
|
staleTime: 30 * 1000, // Cache data for 30 seconds
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import { leaderboards } from "@/common/leaderboards";
|
|
||||||
import ScoreSaberPlayerToken from "@/common/model/token/scoresaber/score-saber-player-token";
|
import ScoreSaberPlayerToken from "@/common/model/token/scoresaber/score-saber-player-token";
|
||||||
import { ScoreSaberPlayersPageToken } from "@/common/model/token/scoresaber/score-saber-players-page-token";
|
import { ScoreSaberPlayersPageToken } from "@/common/model/token/scoresaber/score-saber-players-page-token";
|
||||||
import { formatNumberWithCommas, formatPp } from "@/common/number-utils";
|
import { formatNumberWithCommas, formatPp } from "@/common/number-utils";
|
||||||
@ -10,6 +9,7 @@ import Card from "../card";
|
|||||||
import CountryFlag from "../country-flag";
|
import CountryFlag from "../country-flag";
|
||||||
import { Avatar, AvatarImage } from "../ui/avatar";
|
import { Avatar, AvatarImage } from "../ui/avatar";
|
||||||
import ScoreSaberPlayer from "@/common/model/player/impl/scoresaber-player";
|
import ScoreSaberPlayer from "@/common/model/player/impl/scoresaber-player";
|
||||||
|
import { scoresaberService } from "@/common/service/impl/scoresaber";
|
||||||
|
|
||||||
const REFRESH_INTERVAL = 5 * 60 * 1000; // 5 minutes
|
const REFRESH_INTERVAL = 5 * 60 * 1000; // 5 minutes
|
||||||
const PLAYER_NAME_MAX_LENGTH = 18;
|
const PLAYER_NAME_MAX_LENGTH = 18;
|
||||||
@ -39,7 +39,7 @@ const miniVariants: Variants = {
|
|||||||
return Math.floor((player.rank - 1) / itemsPerPage) + 1;
|
return Math.floor((player.rank - 1) / itemsPerPage) + 1;
|
||||||
},
|
},
|
||||||
query: (page: number) => {
|
query: (page: number) => {
|
||||||
return leaderboards.ScoreSaber.queries.lookupGlobalPlayers(page);
|
return scoresaberService.lookupPlayers(page);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Country: {
|
Country: {
|
||||||
@ -51,10 +51,7 @@ const miniVariants: Variants = {
|
|||||||
return Math.floor((player.countryRank - 1) / itemsPerPage) + 1;
|
return Math.floor((player.countryRank - 1) / itemsPerPage) + 1;
|
||||||
},
|
},
|
||||||
query: (page: number, country: string) => {
|
query: (page: number, country: string) => {
|
||||||
return leaderboards.ScoreSaber.queries.lookupGlobalPlayersByCountry(
|
return scoresaberService.lookupPlayersByCountry(page, country);
|
||||||
page,
|
|
||||||
country,
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user