fix score acc slider not updating the acc and add a loader to the leaderboard dropdown
All checks were successful
Deploy Website / docker (ubuntu-latest) (push) Successful in 2m33s

This commit is contained in:
Lee 2024-10-24 13:30:37 +01:00
parent 9f4e3afffd
commit 1d9433ef02
2 changed files with 22 additions and 14 deletions

@ -7,19 +7,21 @@ import { useToast } from "@/hooks/use-toast";
import { useState } from "react"; import { useState } from "react";
import ScoreButton from "./score-button"; import ScoreButton from "./score-button";
import { copyToClipboard } from "@/common/browser-utils"; 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 clsx from "clsx";
import ScoreEditorButton from "@/components/score/score-editor-button"; import ScoreEditorButton from "@/components/score/score-editor-button";
import { ScoreSaberScore } from "@ssr/common/model/score/impl/scoresaber-score"; import { ScoreSaberScore } from "@ssr/common/model/score/impl/scoresaber-score";
import ScoreSaberLeaderboard from "@ssr/common/leaderboard/impl/scoresaber-leaderboard"; import ScoreSaberLeaderboard from "@ssr/common/leaderboard/impl/scoresaber-leaderboard";
import { BeatSaverMap } from "@ssr/common/model/beatsaver/map"; import { BeatSaverMap } from "@ssr/common/model/beatsaver/map";
import BeatSaberPepeLogo from "@/components/logos/beatsaber-pepe-logo"; import BeatSaberPepeLogo from "@/components/logos/beatsaber-pepe-logo";
import * as React from "react";
type Props = { type Props = {
score?: ScoreSaberScore; score?: ScoreSaberScore;
leaderboard: ScoreSaberLeaderboard; leaderboard: ScoreSaberLeaderboard;
beatSaverMap?: BeatSaverMap; beatSaverMap?: BeatSaverMap;
alwaysSingleLine?: boolean; alwaysSingleLine?: boolean;
isLeaderboardLoading?: boolean;
setIsLeaderboardExpanded?: (isExpanded: boolean) => void; setIsLeaderboardExpanded?: (isExpanded: boolean) => void;
updateScore?: (score: ScoreSaberScore) => void; updateScore?: (score: ScoreSaberScore) => void;
}; };
@ -29,6 +31,7 @@ export default function ScoreButtons({
leaderboard, leaderboard,
beatSaverMap, beatSaverMap,
alwaysSingleLine, alwaysSingleLine,
isLeaderboardLoading,
setIsLeaderboardExpanded, setIsLeaderboardExpanded,
updateScore, updateScore,
}: Props) { }: Props) {
@ -107,6 +110,9 @@ export default function ScoreButtons({
{/* View Leaderboard button */} {/* View Leaderboard button */}
{leaderboardExpanded != undefined && setIsLeaderboardExpanded != undefined && ( {leaderboardExpanded != undefined && setIsLeaderboardExpanded != undefined && (
<div className="flex items-center justify-center cursor-default"> <div className="flex items-center justify-center cursor-default">
{isLeaderboardLoading ? (
<ArrowPathIcon className="w-5 h-5 animate-spin" />
) : (
<ArrowDownIcon <ArrowDownIcon
className={clsx( className={clsx(
"w-6 h-6 transition-all transform-gpu cursor-pointer", "w-6 h-6 transition-all transform-gpu cursor-pointer",
@ -117,6 +123,7 @@ export default function ScoreButtons({
setIsLeaderboardExpanded?.(!leaderboardExpanded); setIsLeaderboardExpanded?.(!leaderboardExpanded);
}} }}
/> />
)}
</div> </div>
)} )}
</div> </div>

@ -102,9 +102,9 @@ export default function Score({ leaderboard, beatSaverMap, score, settings }: Pr
const handleLeaderboardOpen = (isExpanded: boolean) => { const handleLeaderboardOpen = (isExpanded: boolean) => {
if (!isExpanded) { if (!isExpanded) {
setLeaderboardDropdownData(undefined); setLeaderboardDropdownData(undefined);
} } else {
setLoading(true); setLoading(true);
}
setIsLeaderboardExpanded(isExpanded); setIsLeaderboardExpanded(isExpanded);
}; };
@ -148,6 +148,7 @@ export default function Score({ leaderboard, beatSaverMap, score, settings }: Pr
setIsLeaderboardExpanded={(isExpanded: boolean) => { setIsLeaderboardExpanded={(isExpanded: boolean) => {
handleLeaderboardOpen(isExpanded); handleLeaderboardOpen(isExpanded);
}} }}
isLeaderboardLoading={isLoading}
updateScore={score => { updateScore={score => {
setBaseScore(score.score); setBaseScore(score.score);
}} }}
@ -156,7 +157,7 @@ export default function Score({ leaderboard, beatSaverMap, score, settings }: Pr
<ScoreStats <ScoreStats
score={{ score={{
...score, ...score,
score: baseScore, accuracy: accuracy ? accuracy : score.accuracy,
pp: pp ? pp : score.pp, pp: pp ? pp : score.pp,
}} }}
leaderboard={leaderboard} leaderboard={leaderboard}