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;
|
||||
isLeaderboardPage?: boolean;
|
||||
leaderboardChanged?: (id: number) => void;
|
||||
disableUrlChanging?: boolean;
|
||||
};
|
||||
|
||||
export default function LeaderboardScores({
|
||||
@ -34,6 +35,7 @@ export default function LeaderboardScores({
|
||||
showDifficulties,
|
||||
isLeaderboardPage,
|
||||
leaderboardChanged,
|
||||
disableUrlChanging,
|
||||
}: LeaderboardScoresProps) {
|
||||
if (!initialPage) {
|
||||
initialPage = 1;
|
||||
@ -115,9 +117,13 @@ export default function LeaderboardScores({
|
||||
}, [currentPage, topOfScoresRef, shouldFetch]);
|
||||
|
||||
useEffect(() => {
|
||||
if (disableUrlChanging) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Update the URL
|
||||
window.history.replaceState(null, "", `/leaderboard/${selectedLeaderboardId}/${currentPage}`);
|
||||
}, [selectedLeaderboardId, currentPage]);
|
||||
}, [selectedLeaderboardId, currentPage, disableUrlChanging]);
|
||||
|
||||
if (currentScores === undefined) {
|
||||
return undefined;
|
||||
|
@ -103,7 +103,11 @@ export default function Score({ leaderboard, beatSaverMap, score, settings }: Pr
|
||||
animate={{ opacity: 1, y: 0 }}
|
||||
className="w-full mt-2"
|
||||
>
|
||||
<LeaderboardScores initialPage={getPageFromRank(score.rank, 12)} leaderboard={leaderboard} />
|
||||
<LeaderboardScores
|
||||
initialPage={getPageFromRank(score.rank, 12)}
|
||||
leaderboard={leaderboard}
|
||||
disableUrlChanging
|
||||
/>
|
||||
</motion.div>
|
||||
)}
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user