mirror of
https://github.com/ppy/osu.git
synced 2024-09-22 00:47:24 +08:00
Revert changes regarding FrontPageDisplay and OverlayView
This commit is contained in:
parent
c6ae2f520e
commit
788395f8bf
@ -13,16 +13,15 @@ using osuTK;
|
||||
|
||||
namespace osu.Game.Overlays.News.Displays
|
||||
{
|
||||
public class FrontPageDisplay : OverlayView<GetNewsResponse>
|
||||
public class FrontPageDisplay : CompositeDrawable
|
||||
{
|
||||
protected override bool PerformFetchOnApiStateChange => false;
|
||||
|
||||
protected override APIRequest<GetNewsResponse> CreateRequest() => new GetNewsRequest();
|
||||
[Resolved]
|
||||
private IAPIProvider api { get; set; }
|
||||
|
||||
private FillFlowContainer content;
|
||||
private ShowMoreButton showMore;
|
||||
|
||||
private GetNewsRequest olderPostsRequest;
|
||||
private GetNewsRequest request;
|
||||
private Cursor lastCursor;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
@ -62,16 +61,27 @@ namespace osu.Game.Overlays.News.Displays
|
||||
{
|
||||
Top = 15
|
||||
},
|
||||
Action = fetchOlderPosts,
|
||||
Action = performFetch,
|
||||
Alpha = 0
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
performFetch();
|
||||
}
|
||||
|
||||
private void performFetch()
|
||||
{
|
||||
request?.Cancel();
|
||||
|
||||
request = new GetNewsRequest(lastCursor);
|
||||
request.Success += response => Schedule(() => onSuccess(response));
|
||||
api.PerformAsync(request);
|
||||
}
|
||||
|
||||
private CancellationTokenSource cancellationToken;
|
||||
|
||||
protected override void OnSuccess(GetNewsResponse response)
|
||||
private void onSuccess(GetNewsResponse response)
|
||||
{
|
||||
cancellationToken?.Cancel();
|
||||
|
||||
@ -94,18 +104,9 @@ namespace osu.Game.Overlays.News.Displays
|
||||
}, (cancellationToken = new CancellationTokenSource()).Token);
|
||||
}
|
||||
|
||||
private void fetchOlderPosts()
|
||||
{
|
||||
olderPostsRequest?.Cancel();
|
||||
|
||||
olderPostsRequest = new GetNewsRequest(lastCursor);
|
||||
olderPostsRequest.Success += response => Schedule(() => OnSuccess(response));
|
||||
API.PerformAsync(olderPostsRequest);
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
olderPostsRequest?.Cancel();
|
||||
request?.Cancel();
|
||||
cancellationToken?.Cancel();
|
||||
base.Dispose(isDisposing);
|
||||
}
|
||||
|
@ -18,11 +18,6 @@ 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; }
|
||||
|
||||
@ -38,10 +33,6 @@ 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>
|
||||
@ -73,8 +64,7 @@ namespace osu.Game.Overlays
|
||||
switch (state)
|
||||
{
|
||||
case APIState.Online:
|
||||
if (PerformFetchOnApiStateChange)
|
||||
PerformFetch();
|
||||
PerformFetch();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user