mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 11:40:42 +00:00
fix(leaderboards): update & move reached_limit check (#3128)
If this PR fixes an issue, link it below. If not, delete these two lines. Resolves #3126 ## Description: update & move reached_limit check ## Please complete the following: - [X] I have added screenshots for all UI updates - [X] I process any text displayed to the user through translateText() and I've added it to the en.json file - [X] I have added relevant tests to the test directory - [X] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced ## Please put your Discord username so you can be contacted if a bug or regression is found: wraith4081 --------- Co-authored-by: Ryan <7389646+ryanbarlow97@users.noreply.github.com>
This commit is contained in:
+4
-7
@@ -235,13 +235,6 @@ export async function fetchPlayerLeaderboard(
|
||||
});
|
||||
|
||||
if (!res.ok) {
|
||||
// Handle "Page must be between X and Y" error as end of list
|
||||
if (res.status === 400) {
|
||||
const errorJson = await res.json().catch(() => null);
|
||||
if (errorJson?.message?.includes("Page must be between")) {
|
||||
return "reached_limit";
|
||||
}
|
||||
}
|
||||
console.warn(
|
||||
"fetchPlayerLeaderboard: unexpected status",
|
||||
res.status,
|
||||
@@ -253,6 +246,10 @@ export async function fetchPlayerLeaderboard(
|
||||
const json = await res.json();
|
||||
const parsed = RankedLeaderboardResponseSchema.safeParse(json);
|
||||
if (!parsed.success) {
|
||||
// Handle "Page must be between X and Y" error as end of list
|
||||
if (json?.message?.includes?.("Page must be between")) {
|
||||
return "reached_limit";
|
||||
}
|
||||
console.warn(
|
||||
"fetchPlayerLeaderboard: Zod validation failed",
|
||||
parsed.error.toString(),
|
||||
|
||||
Reference in New Issue
Block a user