fix(ssr): fix pagination
All checks were successful
deploy / deploy (push) Successful in 1m1s

This commit is contained in:
Lee 2023-11-08 11:58:36 +00:00
parent 3b2e726fa1
commit 662999f65b
2 changed files with 18 additions and 2 deletions

View File

@ -71,6 +71,7 @@ export default function GlobalRanking({
<Pagination
currentPage={pageInfo.page}
totalPages={pageInfo.totalPages}
useHref
/>
</div>
</div>

View File

@ -47,10 +47,16 @@ export default function Scores({
sortType: initalSortType,
scores: initalScores ? initalScores : [],
});
const [changedPage, setChangedPage] = useState(false);
const updateScoresPage = useCallback(
(sortType: SortType, page: any) => {
if (page == initalPage && sortType == initalSortType && initalScores) {
if (
page == initalPage &&
sortType == initalSortType &&
initalScores &&
!changedPage
) {
console.log("Already loaded scores, not fetching");
return;
}
@ -76,12 +82,21 @@ export default function Scores({
"",
`/player/${playerId}/${sortType.value}/${page}`,
);
setChangedPage(true);
console.log(`Switched page to ${page} with sort ${sortType.value}`);
},
);
},
[initalPage, initalScores, initalSortType, playerId, scores, settingsStore],
[
changedPage,
initalPage,
initalScores,
initalSortType,
playerId,
scores,
settingsStore,
],
);
useEffect(() => {