1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-13 12:02:54 +08:00

Ensure Leaderboard.Scores is updated immediately via request flow

This commit is contained in:
Dean Herbert 2022-09-20 17:01:44 +09:00
parent 1c02fa8399
commit 68c040175a
2 changed files with 20 additions and 15 deletions

View File

@ -185,14 +185,22 @@ namespace osu.Game.Online.Leaderboards
if (scores != null)
this.scores.AddRange(scores);
userScoreContainer.Score.Value = userScore;
// Schedule needs to be non-delayed here for the weird logic in refetchScores to work.
// If it is removed, the placeholder will be incorrectly updated to "no scores" rather than "retrieving".
// This whole flow should be refactored in the future.
Scheduler.Add(applyNewScores, false);
if (userScore == null)
userScoreContainer.Hide();
else
userScoreContainer.Show();
void applyNewScores()
{
userScoreContainer.Score.Value = userScore;
Scheduler.Add(updateScoresDrawables, false);
if (userScore == null)
userScoreContainer.Hide();
else
userScoreContainer.Show();
updateScoresDrawables();
}
}
/// <summary>
@ -212,8 +220,8 @@ namespace osu.Game.Online.Leaderboards
Debug.Assert(ThreadSafety.IsUpdateThread);
cancelPendingWork();
SetScores(null);
SetScores(null);
setState(LeaderboardState.Retrieving);
currentFetchCancellationSource = new CancellationTokenSource();

View File

@ -148,13 +148,10 @@ namespace osu.Game.Screens.Select.Leaderboards
var req = new GetScoresRequest(fetchBeatmapInfo, fetchRuleset, Scope, requestMods);
req.Success += r => Schedule(() =>
{
SetScores(
scoreManager.OrderByTotalScore(r.Scores.Select(s => s.ToScoreInfo(rulesets, fetchBeatmapInfo))),
r.UserScore?.CreateScoreInfo(rulesets, fetchBeatmapInfo)
);
});
req.Success += r => SetScores(
scoreManager.OrderByTotalScore(r.Scores.Select(s => s.ToScoreInfo(rulesets, fetchBeatmapInfo))),
r.UserScore?.CreateScoreInfo(rulesets, fetchBeatmapInfo)
);
return req;
}
@ -209,7 +206,7 @@ namespace osu.Game.Screens.Select.Leaderboards
scores = scoreManager.OrderByTotalScore(scores.Detach());
Schedule(() => SetScores(scores));
SetScores(scores);
}
}