Skip to content

Commit 70e5603

Browse files
committed
fix(ranking): 修复对于第一次参赛的选手,获取初始分数错误
1 parent 539180e commit 70e5603

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/content/pages/ranking/rankSlice.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,9 @@ export const fetchUserRating = createAsyncThunk<
181181
res = await query({ message: { type: 'get-user-ranking', username } })
182182
}
183183
const { start_time } = getState().contestInfos[contestSlug].info!.contest
184-
const history = res.userContestRankingHistory.filter(a => a.attended)
185184

186-
let l = 0,
185+
const history = res.userContestRankingHistory?.filter(a => a.attended) ?? []
186+
let l = -1,
187187
r = history.length - 1
188188
while (l < r) {
189189
const m = (l + r + 1) >> 1
@@ -194,7 +194,7 @@ export const fetchUserRating = createAsyncThunk<
194194
}
195195
}
196196

197-
return { oldRating: history[l].rating ?? 1500, acc: l + 1 }
197+
return { oldRating: history[l]?.rating ?? 1500, acc: l + 1 }
198198
}
199199
)
200200

0 commit comments

Comments
 (0)