fix the url randomly switching to a leaderboard
All checks were successful
Deploy Website / docker (ubuntu-latest) (push) Successful in 2m10s
All checks were successful
Deploy Website / docker (ubuntu-latest) (push) Successful in 2m10s
This commit is contained in:
parent
2df95d140a
commit
1e8c38eb26
@ -25,6 +25,7 @@ type LeaderboardScoresProps = {
|
|||||||
showDifficulties?: boolean;
|
showDifficulties?: boolean;
|
||||||
isLeaderboardPage?: boolean;
|
isLeaderboardPage?: boolean;
|
||||||
leaderboardChanged?: (id: number) => void;
|
leaderboardChanged?: (id: number) => void;
|
||||||
|
disableUrlChanging?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function LeaderboardScores({
|
export default function LeaderboardScores({
|
||||||
@ -34,6 +35,7 @@ export default function LeaderboardScores({
|
|||||||
showDifficulties,
|
showDifficulties,
|
||||||
isLeaderboardPage,
|
isLeaderboardPage,
|
||||||
leaderboardChanged,
|
leaderboardChanged,
|
||||||
|
disableUrlChanging,
|
||||||
}: LeaderboardScoresProps) {
|
}: LeaderboardScoresProps) {
|
||||||
if (!initialPage) {
|
if (!initialPage) {
|
||||||
initialPage = 1;
|
initialPage = 1;
|
||||||
@ -115,9 +117,13 @@ export default function LeaderboardScores({
|
|||||||
}, [currentPage, topOfScoresRef, shouldFetch]);
|
}, [currentPage, topOfScoresRef, shouldFetch]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (disableUrlChanging) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Update the URL
|
// Update the URL
|
||||||
window.history.replaceState(null, "", `/leaderboard/${selectedLeaderboardId}/${currentPage}`);
|
window.history.replaceState(null, "", `/leaderboard/${selectedLeaderboardId}/${currentPage}`);
|
||||||
}, [selectedLeaderboardId, currentPage]);
|
}, [selectedLeaderboardId, currentPage, disableUrlChanging]);
|
||||||
|
|
||||||
if (currentScores === undefined) {
|
if (currentScores === undefined) {
|
||||||
return undefined;
|
return undefined;
|
||||||
|
@ -103,7 +103,11 @@ export default function Score({ leaderboard, beatSaverMap, score, settings }: Pr
|
|||||||
animate={{ opacity: 1, y: 0 }}
|
animate={{ opacity: 1, y: 0 }}
|
||||||
className="w-full mt-2"
|
className="w-full mt-2"
|
||||||
>
|
>
|
||||||
<LeaderboardScores initialPage={getPageFromRank(score.rank, 12)} leaderboard={leaderboard} />
|
<LeaderboardScores
|
||||||
|
initialPage={getPageFromRank(score.rank, 12)}
|
||||||
|
leaderboard={leaderboard}
|
||||||
|
disableUrlChanging
|
||||||
|
/>
|
||||||
</motion.div>
|
</motion.div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
Reference in New Issue
Block a user