Debounce schedule at base class

This commit is contained in:
Dean Herbert 2021-06-14 14:26:40 +09:00
parent 8dd48d48f6
commit fc442713bb
2 changed files with 7 additions and 7 deletions

View File

@ -126,7 +126,7 @@ public TScope Scope
return;
scope = value;
UpdateScores();
RefreshScores();
}
}
@ -154,7 +154,7 @@ protected PlaceholderState PlaceholderState
case PlaceholderState.NetworkFailure:
replacePlaceholder(new ClickablePlaceholder(@"Couldn't fetch scores!", FontAwesome.Solid.Sync)
{
Action = UpdateScores,
Action = RefreshScores
});
break;
@ -254,8 +254,6 @@ private void load()
apiState.BindValueChanged(onlineStateChanged, true);
}
public void RefreshScores() => UpdateScores();
private APIRequest getScoresRequest;
protected abstract bool IsOnlineScope { get; }
@ -267,12 +265,14 @@ private void onlineStateChanged(ValueChangedEvent<APIState> state) => Schedule((
case APIState.Online:
case APIState.Offline:
if (IsOnlineScope)
UpdateScores();
RefreshScores();
break;
}
});
public void RefreshScores() => Scheduler.AddOnce(UpdateScores);
protected void UpdateScores()
{
// don't display any scores or placeholder until the first Scores_Set has been called.

View File

@ -103,7 +103,7 @@ private void onScoreRemoved(ValueChangedEvent<WeakReference<ScoreInfo>> score)
if (Scope != BeatmapLeaderboardScope.Local)
return;
Scheduler.AddOnce(RefreshScores);
RefreshScores();
}
private void onScoreAdded(ValueChangedEvent<WeakReference<ScoreInfo>> score)
@ -111,7 +111,7 @@ private void onScoreAdded(ValueChangedEvent<WeakReference<ScoreInfo>> score)
if (Scope != BeatmapLeaderboardScope.Local)
return;
Scheduler.AddOnce(RefreshScores);
RefreshScores();
}
protected override bool IsOnlineScope => Scope != BeatmapLeaderboardScope.Local;