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

Fix leaderboard potentially displaying the wrong scores

Closes #14762.

This class is ugly. I think the whole process should be clened up once
we have correctly-scheduled `SynchronizationContext`s. There's not much
saving it as long as all these interdispersed `Schedule`s around
required.
This commit is contained in:
Dean Herbert 2021-10-06 16:07:27 +09:00
parent e6aa05a4a4
commit 3803f2f462

View File

@ -255,6 +255,7 @@ namespace osu.Game.Online.Leaderboards
} }
private APIRequest getScoresRequest; private APIRequest getScoresRequest;
private ScheduledDelegate getScoresRequestCallback;
protected abstract bool IsOnlineScope { get; } protected abstract bool IsOnlineScope { get; }
@ -282,13 +283,16 @@ namespace osu.Game.Online.Leaderboards
getScoresRequest?.Cancel(); getScoresRequest?.Cancel();
getScoresRequest = null; getScoresRequest = null;
getScoresRequestCallback?.Cancel();
getScoresRequestCallback = null;
pendingUpdateScores?.Cancel(); pendingUpdateScores?.Cancel();
pendingUpdateScores = Schedule(() => pendingUpdateScores = Schedule(() =>
{ {
PlaceholderState = PlaceholderState.Retrieving; PlaceholderState = PlaceholderState.Retrieving;
loading.Show(); loading.Show();
getScoresRequest = FetchScores(scores => Schedule(() => getScoresRequest = FetchScores(scores => getScoresRequestCallback = Schedule(() =>
{ {
Scores = scores.ToArray(); Scores = scores.ToArray();
PlaceholderState = Scores.Any() ? PlaceholderState.Successful : PlaceholderState.NoScores; PlaceholderState = Scores.Any() ? PlaceholderState.Successful : PlaceholderState.NoScores;
@ -297,7 +301,7 @@ namespace osu.Game.Online.Leaderboards
if (getScoresRequest == null) if (getScoresRequest == null)
return; return;
getScoresRequest.Failure += e => Schedule(() => getScoresRequest.Failure += e => getScoresRequestCallback = Schedule(() =>
{ {
if (e is OperationCanceledException) if (e is OperationCanceledException)
return; return;