mirror of
https://github.com/wassname/Open-Assistant.git
synced 2026-06-27 16:10:30 +08:00
fix leaderboard when current user doesn't have stats (#1289)
This commit is contained in:
@@ -34,7 +34,7 @@ export const LeaderboardTable = ({
|
||||
data: reply,
|
||||
isLoading,
|
||||
error,
|
||||
} = useSWRImmutable<LeaderboardReply & { user_stats_window: LeaderboardReply["leaderboard"] }>(
|
||||
} = useSWRImmutable<LeaderboardReply & { user_stats_window?: LeaderboardReply["leaderboard"] }>(
|
||||
`/api/leaderboard?time_frame=${timeFrame}&limit=${limit}&includeUserStats=${!hideCurrentUserRanking}`,
|
||||
get
|
||||
);
|
||||
@@ -79,7 +79,7 @@ export const LeaderboardTable = ({
|
||||
const start = (page - 1) * rowPerPage;
|
||||
const end = start + rowPerPage;
|
||||
const leaderBoardEntities = reply.leaderboard.slice(start, end);
|
||||
if (hideCurrentUserRanking) {
|
||||
if (hideCurrentUserRanking || !reply.user_stats_window) {
|
||||
return leaderBoardEntities;
|
||||
}
|
||||
const userStatsWindow: WindowLeaderboardEntity[] = reply.user_stats_window;
|
||||
|
||||
@@ -29,7 +29,7 @@ const handler = withoutRole("banned", async (req, res, token) => {
|
||||
|
||||
res.status(200).json({
|
||||
...leaderboard,
|
||||
user_stats_window: user_stats.leaderboard.map((stats) => ({ ...stats, is_window: true })),
|
||||
user_stats_window: user_stats?.leaderboard.map((stats) => ({ ...stats, is_window: true })),
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user