Fix: Validate songId as number and add user notification for leaderboard submission
This commit is contained in:
@@ -77,9 +77,16 @@ 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)
|
||||
this.leaderboardData = []
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
var response = await loader.ajax(
|
||||
`${gameConfig.basedir || "/"}api/leaderboard/get?song_id=${this.songId}&difficulty=${this.difficulty}`
|
||||
`${gameConfig.basedir || "/"}api/leaderboard/get?song_id=${parseInt(this.songId)}&difficulty=${this.difficulty}`
|
||||
)
|
||||
var data = JSON.parse(response)
|
||||
if (data.status === "ok") {
|
||||
@@ -94,6 +101,7 @@ class Leaderboard {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
changeDifficulty(direction) {
|
||||
var difficulties = ["easy", "normal", "hard", "oni", "ura"]
|
||||
var currentIndex = difficulties.indexOf(this.difficulty)
|
||||
|
||||
Reference in New Issue
Block a user