Fix: Support both numeric and hash song IDs for leaderboard
This commit is contained in:
@@ -77,17 +77,18 @@ class Leaderboard {
|
||||
}
|
||||
|
||||
async fetchLeaderboard() {
|
||||
// Validate songId is a valid number
|
||||
if (!this.songId || isNaN(parseInt(this.songId))) {
|
||||
console.error("Invalid song ID for leaderboard:", this.songId)
|
||||
// Validate songId exists
|
||||
if (!this.songId) {
|
||||
console.error("Missing song ID for leaderboard")
|
||||
this.leaderboardData = []
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
var response = await loader.ajax(
|
||||
`${gameConfig.basedir || "/"}api/leaderboard/get?song_id=${parseInt(this.songId)}&difficulty=${this.difficulty}`
|
||||
`${gameConfig.basedir || "/"}api/leaderboard/get?song_id=${encodeURIComponent(this.songId)}&difficulty=${this.difficulty}`
|
||||
)
|
||||
|
||||
var data = JSON.parse(response)
|
||||
if (data.status === "ok") {
|
||||
this.leaderboardData = data.leaderboard || []
|
||||
|
||||
Reference in New Issue
Block a user