1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 01:52:55 +08:00

Remove pointless level of schedule/cancel logic

This commit is contained in:
Dean Herbert 2022-01-28 21:47:28 +09:00
parent 64925b3fea
commit 17aa9f3040

View File

@ -54,8 +54,6 @@ namespace osu.Game.Online.Leaderboards
[Resolved(CanBeNull = true)] [Resolved(CanBeNull = true)]
private IAPIProvider api { get; set; } private IAPIProvider api { get; set; }
private ScheduledDelegate pendingUpdateScores;
private readonly IBindable<APIState> apiState = new Bindable<APIState>(); private readonly IBindable<APIState> apiState = new Bindable<APIState>();
private ICollection<TScoreInfo> scores; private ICollection<TScoreInfo> scores;
@ -248,7 +246,6 @@ namespace osu.Game.Online.Leaderboards
protected virtual void Reset() protected virtual void Reset()
{ {
cancelPendingWork(); cancelPendingWork();
Scores = null; Scores = null;
} }
@ -286,30 +283,27 @@ namespace osu.Game.Online.Leaderboards
cancelPendingWork(); cancelPendingWork();
pendingUpdateScores = Schedule(() => PlaceholderState = PlaceholderState.Retrieving;
loading.Show();
getScoresRequest = FetchScores(scores => getScoresRequestCallback = Schedule(() =>
{ {
PlaceholderState = PlaceholderState.Retrieving; Scores = scores.ToArray();
loading.Show(); PlaceholderState = Scores.Any() ? PlaceholderState.Successful : PlaceholderState.NoScores;
}));
getScoresRequest = FetchScores(scores => getScoresRequestCallback = Schedule(() => if (getScoresRequest == null)
{ return;
Scores = scores.ToArray();
PlaceholderState = Scores.Any() ? PlaceholderState.Successful : PlaceholderState.NoScores;
}));
if (getScoresRequest == null) getScoresRequest.Failure += e => getScoresRequestCallback = Schedule(() =>
{
if (e is OperationCanceledException)
return; return;
getScoresRequest.Failure += e => getScoresRequestCallback = Schedule(() => PlaceholderState = PlaceholderState.NetworkFailure;
{
if (e is OperationCanceledException)
return;
PlaceholderState = PlaceholderState.NetworkFailure;
});
api?.Queue(getScoresRequest);
}); });
api?.Queue(getScoresRequest);
} }
private void cancelPendingWork() private void cancelPendingWork()
@ -319,9 +313,6 @@ namespace osu.Game.Online.Leaderboards
getScoresRequestCallback?.Cancel(); getScoresRequestCallback?.Cancel();
getScoresRequestCallback = null; getScoresRequestCallback = null;
pendingUpdateScores?.Cancel();
pendingUpdateScores = null;
} }
/// <summary> /// <summary>