Compare commits
No commits in common. "d08f81b25d403c7bd0d7b703f338da7ed6306ee8" and "0231c6ccfe7fdcdb1519130da5593b5cae63e849" have entirely different histories.
d08f81b25d
...
0231c6ccfe
@ -1,11 +1,12 @@
|
||||
import { Metadata } from "../types/metadata";
|
||||
import { BeatSaverMap } from "../model/beatsaver/beatsaver-map";
|
||||
import Score from "../score/score";
|
||||
|
||||
export default interface LeaderboardScoresResponse<S, L> {
|
||||
export default interface LeaderboardScoresResponse<L> {
|
||||
/**
|
||||
* The scores that were set.
|
||||
*/
|
||||
readonly scores: S[];
|
||||
readonly scores: Score[];
|
||||
|
||||
/**
|
||||
* The leaderboard that was used.
|
||||
|
@ -3,7 +3,6 @@ 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
|
||||
@ -34,5 +33,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<LeaderboardScoresResponse<S, L>>(`${Config.apiUrl}/scores/leaderboard/${leaderboard}/${id}/${page}`);
|
||||
return kyFetch<PlayerScoresResponse<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,5 +121,7 @@ export default async function LeaderboardPage(props: Props) {
|
||||
if (response == undefined) {
|
||||
return redirect("/");
|
||||
}
|
||||
return <LeaderboardData initialLeaderboard={response.leaderboardResponse} initialScores={response.scores} />;
|
||||
const { leaderboardResponse, scores } = response;
|
||||
|
||||
return <LeaderboardData initialLeaderboard={response.leaderboardResponse} initialScores={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 LeaderboardScoresResponse from "@ssr/common/response/leaderboard-scores-response";
|
||||
import PlayerScoresResponse from "../../../../common/src/response/player-scores-response.ts";
|
||||
|
||||
const REFRESH_INTERVAL = 1000 * 60 * 5;
|
||||
|
||||
@ -21,7 +21,7 @@ type LeaderboardDataProps = {
|
||||
/**
|
||||
* The initial score data.
|
||||
*/
|
||||
initialScores?: LeaderboardScoresResponse<ScoreSaberScore, ScoreSaberLeaderboard>;
|
||||
initialScores: PlayerScoresResponse<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 ScoreSaberLeaderboard from "@ssr/common/leaderboard/impl/scoresaber-leaderboard";
|
||||
import ScoreSaberScore from "@ssr/common/score/impl/scoresaber-score";
|
||||
import ScoreSaberLeaderboard from "@ssr/common/leaderboard/impl/scoresaber-leaderboard";
|
||||
|
||||
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 LeaderboardScoresResponse from "@ssr/common/response/leaderboard-scores-response";
|
||||
import PlayerScoresResponse from "../../../../common/src/response/player-scores-response.ts";
|
||||
|
||||
type LeaderboardScoresProps = {
|
||||
/**
|
||||
@ -26,7 +26,7 @@ type LeaderboardScoresProps = {
|
||||
/**
|
||||
* The initial scores to show.
|
||||
*/
|
||||
initialScores?: LeaderboardScoresResponse<ScoreSaberScore, ScoreSaberLeaderboard>;
|
||||
initialScores?: PlayerScoresResponse<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<
|
||||
LeaderboardScoresResponse<ScoreSaberScore, ScoreSaberLeaderboard> | undefined
|
||||
PlayerScoresResponse<ScoreSaberScore, ScoreSaberLeaderboard> | undefined
|
||||
>(initialScores);
|
||||
const topOfScoresRef = useRef<HTMLDivElement>(null);
|
||||
const [shouldFetch, setShouldFetch] = useState(true);
|
||||
|
Reference in New Issue
Block a user