mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 20:22:55 +08:00
Fix FrontPageDisplay is adding more news posts on api state change
This commit is contained in:
parent
7e5147761f
commit
c6ae2f520e
@ -15,6 +15,8 @@ namespace osu.Game.Overlays.News.Displays
|
||||
{
|
||||
public class FrontPageDisplay : OverlayView<GetNewsResponse>
|
||||
{
|
||||
protected override bool PerformFetchOnApiStateChange => false;
|
||||
|
||||
protected override APIRequest<GetNewsResponse> CreateRequest() => new GetNewsRequest();
|
||||
|
||||
private FillFlowContainer content;
|
||||
|
@ -18,6 +18,11 @@ namespace osu.Game.Overlays
|
||||
public abstract class OverlayView<T> : CompositeDrawable, IOnlineComponent
|
||||
where T : class
|
||||
{
|
||||
/// <summary>
|
||||
/// Whether we should perform fetch on api state change to online (true by default).
|
||||
/// </summary>
|
||||
protected virtual bool PerformFetchOnApiStateChange => true;
|
||||
|
||||
[Resolved]
|
||||
protected IAPIProvider API { get; private set; }
|
||||
|
||||
@ -33,6 +38,10 @@ namespace osu.Game.Overlays
|
||||
{
|
||||
base.LoadComplete();
|
||||
API.Register(this);
|
||||
|
||||
// If property is true - fetch will be triggered automatically by APIStateChanged and if not - we need to manually call it.
|
||||
if (!PerformFetchOnApiStateChange)
|
||||
PerformFetch();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -64,7 +73,8 @@ namespace osu.Game.Overlays
|
||||
switch (state)
|
||||
{
|
||||
case APIState.Online:
|
||||
PerformFetch();
|
||||
if (PerformFetchOnApiStateChange)
|
||||
PerformFetch();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user