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
All checks were successful
Deploy Website / docker (ubuntu-latest) (push) Successful in 2m33s
This commit is contained in:
parent
9f4e3afffd
commit
1d9433ef02
@ -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,16 +110,20 @@ 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">
|
||||||
<ArrowDownIcon
|
{isLeaderboardLoading ? (
|
||||||
className={clsx(
|
<ArrowPathIcon className="w-5 h-5 animate-spin" />
|
||||||
"w-6 h-6 transition-all transform-gpu cursor-pointer",
|
) : (
|
||||||
leaderboardExpanded ? "" : "rotate-180"
|
<ArrowDownIcon
|
||||||
)}
|
className={clsx(
|
||||||
onClick={() => {
|
"w-6 h-6 transition-all transform-gpu cursor-pointer",
|
||||||
setLeaderboardExpanded(!leaderboardExpanded);
|
leaderboardExpanded ? "" : "rotate-180"
|
||||||
setIsLeaderboardExpanded?.(!leaderboardExpanded);
|
)}
|
||||||
}}
|
onClick={() => {
|
||||||
/>
|
setLeaderboardExpanded(!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}
|
||||||
|
Reference in New Issue
Block a user