Compare commits
2 Commits
0231c6ccfe
...
d08f81b25d
Author | SHA1 | Date | |
---|---|---|---|
d08f81b25d | |||
e37f0d5548 |
@ -1,12 +1,11 @@
|
||||
import { Metadata } from "../types/metadata";
|
||||
import { BeatSaverMap } from "../model/beatsaver/beatsaver-map";
|
||||
import Score from "../score/score";
|
||||
|
||||
export default interface LeaderboardScoresResponse<L> {
|
||||
export default interface LeaderboardScoresResponse<S, L> {
|
||||
/**
|
||||
* The scores that were set.
|
||||
*/
|
||||
readonly scores: Score[];
|
||||
readonly scores: S[];
|
||||
|
||||
/**
|
||||
* The leaderboard that was used.
|
||||
|
@ -3,6 +3,7 @@ import { kyFetch } from "./utils";
|
||||
import PlayerScoresResponse from "../response/player-scores-response";
|
||||
import { Config } from "../config";
|
||||
import { ScoreSort } from "../score/score-sort";
|
||||
import LeaderboardScoresResponse from "../response/leaderboard-scores-response";
|
||||
|
||||
/**
|
||||
* Fetches the player's scores
|
||||
@ -33,5 +34,5 @@ export async function fetchPlayerScores<S, L>(
|
||||
* @param page the page
|
||||
*/
|
||||
export async function fetchLeaderboardScores<S, L>(leaderboard: Leaderboards, id: string, page: number) {
|
||||
return kyFetch<PlayerScoresResponse<S, L>>(`${Config.apiUrl}/scores/leaderboard/${leaderboard}/${id}/${page}`);
|
||||
return kyFetch<LeaderboardScoresResponse<S, L>>(`${Config.apiUrl}/scores/leaderboard/${leaderboard}/${id}/${page}`);
|
||||
}
|
||||
|
@ -9,8 +9,8 @@ import ScoreSaberScore from "@ssr/common/score/impl/scoresaber-score";
|
||||
import { LeaderboardResponse } from "@ssr/common/response/leaderboard-response";
|
||||
import ScoreSaberLeaderboard from "@ssr/common/leaderboard/impl/scoresaber-leaderboard";
|
||||
import { fetchLeaderboard } from "@ssr/common/utils/leaderboard.util";
|
||||
import PlayerScoresResponse from "../../../../../../common/src/response/player-scores-response.ts";
|
||||
import { fetchLeaderboardScores } from "@ssr/common/utils/score-utils";
|
||||
import PlayerScoresResponse from "@ssr/common/response/player-scores-response";
|
||||
|
||||
const UNKNOWN_LEADERBOARD = {
|
||||
title: "ScoreSaber Reloaded - Unknown Leaderboard",
|
||||
@ -121,7 +121,5 @@ export default async function LeaderboardPage(props: Props) {
|
||||
if (response == undefined) {
|
||||
return redirect("/");
|
||||
}
|
||||
const { leaderboardResponse, scores } = response;
|
||||
|
||||
return <LeaderboardData initialLeaderboard={response.leaderboardResponse} initialScores={scores} />;
|
||||
return <LeaderboardData initialLeaderboard={response.leaderboardResponse} initialScores={response.scores} />;
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ import { LeaderboardResponse } from "@ssr/common/response/leaderboard-response";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { useState } from "react";
|
||||
import { fetchLeaderboard } from "@ssr/common/utils/leaderboard.util";
|
||||
import PlayerScoresResponse from "../../../../common/src/response/player-scores-response.ts";
|
||||
import LeaderboardScoresResponse from "@ssr/common/response/leaderboard-scores-response";
|
||||
|
||||
const REFRESH_INTERVAL = 1000 * 60 * 5;
|
||||
|
||||
@ -21,7 +21,7 @@ type LeaderboardDataProps = {
|
||||
/**
|
||||
* The initial score data.
|
||||
*/
|
||||
initialScores: PlayerScoresResponse<ScoreSaberScore, ScoreSaberLeaderboard>;
|
||||
initialScores?: LeaderboardScoresResponse<ScoreSaberScore, ScoreSaberLeaderboard>;
|
||||
};
|
||||
|
||||
export function LeaderboardData({ initialLeaderboard, initialScores }: LeaderboardDataProps) {
|
||||
|
@ -2,8 +2,8 @@ import LeaderboardPlayer from "./leaderboard-player";
|
||||
import LeaderboardScoreStats from "./leaderboard-score-stats";
|
||||
import ScoreRankInfo from "@/components/score/score-rank-info";
|
||||
import ScoreSaberPlayer from "@ssr/common/player/impl/scoresaber-player";
|
||||
import ScoreSaberScore from "@ssr/common/score/impl/scoresaber-score";
|
||||
import ScoreSaberLeaderboard from "@ssr/common/leaderboard/impl/scoresaber-leaderboard";
|
||||
import ScoreSaberScore from "@ssr/common/score/impl/scoresaber-score";
|
||||
|
||||
type Props = {
|
||||
/**
|
||||
|
@ -15,7 +15,7 @@ import { fetchLeaderboardScores } from "@ssr/common/utils/score-utils";
|
||||
import ScoreSaberScore from "@ssr/common/score/impl/scoresaber-score";
|
||||
import ScoreSaberLeaderboard from "@ssr/common/leaderboard/impl/scoresaber-leaderboard";
|
||||
import ScoreSaberPlayer from "@ssr/common/player/impl/scoresaber-player";
|
||||
import PlayerScoresResponse from "../../../../common/src/response/player-scores-response.ts";
|
||||
import LeaderboardScoresResponse from "@ssr/common/response/leaderboard-scores-response";
|
||||
|
||||
type LeaderboardScoresProps = {
|
||||
/**
|
||||
@ -26,7 +26,7 @@ type LeaderboardScoresProps = {
|
||||
/**
|
||||
* The initial scores to show.
|
||||
*/
|
||||
initialScores?: PlayerScoresResponse<ScoreSaberScore, ScoreSaberLeaderboard>;
|
||||
initialScores?: LeaderboardScoresResponse<ScoreSaberScore, ScoreSaberLeaderboard>;
|
||||
|
||||
/**
|
||||
* The leaderboard to display.
|
||||
@ -75,7 +75,7 @@ export default function LeaderboardScores({
|
||||
const [previousPage, setPreviousPage] = useState(initialPage);
|
||||
const [currentPage, setCurrentPage] = useState(initialPage);
|
||||
const [currentScores, setCurrentScores] = useState<
|
||||
PlayerScoresResponse<ScoreSaberScore, ScoreSaberLeaderboard> | undefined
|
||||
LeaderboardScoresResponse<ScoreSaberScore, ScoreSaberLeaderboard> | undefined
|
||||
>(initialScores);
|
||||
const topOfScoresRef = useRef<HTMLDivElement>(null);
|
||||
const [shouldFetch, setShouldFetch] = useState(true);
|
||||
|
Reference in New Issue
Block a user