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) {
|
if (this.leaderboardSubmitted) {
|
||||||
return
|
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) {
|
if (!this.leaderboardData || !this.leaderboardData.songId) {
|
||||||
this.showLeaderboardNotification("no_song_id")
|
this.showLeaderboardNotification("no_song_id")
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -359,6 +359,7 @@ class Search{
|
|||||||
}
|
}
|
||||||
|
|
||||||
highlightResult(text, result) {
|
highlightResult(text, result) {
|
||||||
|
if (text === null || text === undefined) return document.createDocumentFragment();
|
||||||
var fragment = document.createDocumentFragment()
|
var fragment = document.createDocumentFragment()
|
||||||
var ranges = (result ? result.ranges : null) || []
|
var ranges = (result ? result.ranges : null) || []
|
||||||
var lastIdx = 0
|
var lastIdx = 0
|
||||||
|
|||||||
Reference in New Issue
Block a user