1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 17:32:54 +08:00

Fix FrontPageDisplay is adding more news posts on api state change

This commit is contained in:
Andrei Zavatski 2020-07-25 10:39:10 +03:00
parent 7e5147761f
commit c6ae2f520e
2 changed files with 13 additions and 1 deletions

View File

@ -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;

View File

@ -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;
}
}