diff --git a/projects/website/src/components/score/score-buttons.tsx b/projects/website/src/components/score/score-buttons.tsx index aa391c0..51d1b42 100644 --- a/projects/website/src/components/score/score-buttons.tsx +++ b/projects/website/src/components/score/score-buttons.tsx @@ -7,19 +7,21 @@ import { useToast } from "@/hooks/use-toast"; import { useState } from "react"; import ScoreButton from "./score-button"; import { copyToClipboard } from "@/common/browser-utils"; -import { ArrowDownIcon } from "@heroicons/react/24/solid"; +import { ArrowDownIcon, ArrowPathIcon } from "@heroicons/react/24/solid"; import clsx from "clsx"; import ScoreEditorButton from "@/components/score/score-editor-button"; import { ScoreSaberScore } from "@ssr/common/model/score/impl/scoresaber-score"; import ScoreSaberLeaderboard from "@ssr/common/leaderboard/impl/scoresaber-leaderboard"; import { BeatSaverMap } from "@ssr/common/model/beatsaver/map"; import BeatSaberPepeLogo from "@/components/logos/beatsaber-pepe-logo"; +import * as React from "react"; type Props = { score?: ScoreSaberScore; leaderboard: ScoreSaberLeaderboard; beatSaverMap?: BeatSaverMap; alwaysSingleLine?: boolean; + isLeaderboardLoading?: boolean; setIsLeaderboardExpanded?: (isExpanded: boolean) => void; updateScore?: (score: ScoreSaberScore) => void; }; @@ -29,6 +31,7 @@ export default function ScoreButtons({ leaderboard, beatSaverMap, alwaysSingleLine, + isLeaderboardLoading, setIsLeaderboardExpanded, updateScore, }: Props) { @@ -107,16 +110,20 @@ export default function ScoreButtons({ {/* View Leaderboard button */} {leaderboardExpanded != undefined && setIsLeaderboardExpanded != undefined && (
- { - setLeaderboardExpanded(!leaderboardExpanded); - setIsLeaderboardExpanded?.(!leaderboardExpanded); - }} - /> + {isLeaderboardLoading ? ( + + ) : ( + { + setLeaderboardExpanded(!leaderboardExpanded); + setIsLeaderboardExpanded?.(!leaderboardExpanded); + }} + /> + )}
)} diff --git a/projects/website/src/components/score/score.tsx b/projects/website/src/components/score/score.tsx index b9d8302..7efbfa5 100644 --- a/projects/website/src/components/score/score.tsx +++ b/projects/website/src/components/score/score.tsx @@ -102,9 +102,9 @@ export default function Score({ leaderboard, beatSaverMap, score, settings }: Pr const handleLeaderboardOpen = (isExpanded: boolean) => { if (!isExpanded) { setLeaderboardDropdownData(undefined); + } else { + setLoading(true); } - - setLoading(true); setIsLeaderboardExpanded(isExpanded); }; @@ -148,6 +148,7 @@ export default function Score({ leaderboard, beatSaverMap, score, settings }: Pr setIsLeaderboardExpanded={(isExpanded: boolean) => { handleLeaderboardOpen(isExpanded); }} + isLeaderboardLoading={isLoading} updateScore={score => { setBaseScore(score.score); }} @@ -156,7 +157,7 @@ export default function Score({ leaderboard, beatSaverMap, score, settings }: Pr