Merge pull request #15649 from peppy/fix-leaderboard-cancellation-failure

Fix song select leaderboard potentially displaying outdated or incorrect content
This commit is contained in:
Dan Balasescu 2021-11-16 19:10:48 +09:00 committed by GitHub
commit 843b0f9641
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -116,6 +116,8 @@ namespace osu.Game.Screens.Select.Leaderboards
loadCancellationSource?.Cancel();
loadCancellationSource = new CancellationTokenSource();
var cancellationToken = loadCancellationSource.Token;
if (BeatmapInfo == null)
{
PlaceholderState = PlaceholderState.NoneSelected;
@ -140,7 +142,7 @@ namespace osu.Game.Screens.Select.Leaderboards
scores = scores.Where(s => s.Mods.Any(m => selectedMods.Contains(m.Acronym)));
}
scoreManager.OrderByTotalScoreAsync(scores.ToArray(), loadCancellationSource.Token)
scoreManager.OrderByTotalScoreAsync(scores.ToArray(), cancellationToken)
.ContinueWith(ordered => scoresCallback?.Invoke(ordered.Result), TaskContinuationOptions.OnlyOnRanToCompletion);
return null;
@ -176,10 +178,10 @@ namespace osu.Game.Screens.Select.Leaderboards
req.Success += r =>
{
scoreManager.OrderByTotalScoreAsync(r.Scores.Select(s => s.CreateScoreInfo(rulesets, BeatmapInfo)).ToArray(), loadCancellationSource.Token)
scoreManager.OrderByTotalScoreAsync(r.Scores.Select(s => s.CreateScoreInfo(rulesets, BeatmapInfo)).ToArray(), cancellationToken)
.ContinueWith(ordered => Schedule(() =>
{
if (loadCancellationSource.IsCancellationRequested)
if (cancellationToken.IsCancellationRequested)
return;
scoresCallback?.Invoke(ordered.Result);