Fix: Add robust leaderboard submission fallback and fix search.js crash
This commit is contained in:
@@ -221,6 +221,33 @@ class Scoresheet {
|
||||
if (this.leaderboardSubmitted) {
|
||||
return
|
||||
}
|
||||
|
||||
// Fallback: This is CRITICAL for cases where saveScore() failed or was skipped
|
||||
if (!this.leaderboardData) {
|
||||
console.warn("Leaderboard data missing, attempting to reconstruct...")
|
||||
var song = this.controller.selectedSong
|
||||
var results = this.resultsObj
|
||||
|
||||
if (song && results) {
|
||||
var songId = song.id || song.hash
|
||||
|
||||
if (songId) {
|
||||
this.leaderboardData = {
|
||||
songId: songId,
|
||||
difficulty: results.difficulty,
|
||||
scoreObj: Object.assign({}, results)
|
||||
}
|
||||
// Clean up scoreObj
|
||||
if (this.leaderboardData.scoreObj) {
|
||||
delete this.leaderboardData.scoreObj.title
|
||||
delete this.leaderboardData.scoreObj.difficulty
|
||||
delete this.leaderboardData.scoreObj.gauge
|
||||
}
|
||||
console.log("Leaderboard data reconstructed:", this.leaderboardData)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.leaderboardData || !this.leaderboardData.songId) {
|
||||
this.showLeaderboardNotification("no_song_id")
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user