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

Pass fetch more action in via ctor to avoid potential nullref

This commit is contained in:
Dean Herbert 2021-05-26 22:49:39 +09:00
parent 9947867e84
commit 735e7b9c74
2 changed files with 10 additions and 5 deletions

View File

@ -19,11 +19,18 @@ namespace osu.Game.Overlays.News.Displays
/// </summary>
public class ArticleListing : CompositeDrawable
{
public Action RequestMorePosts;
private readonly Action fetchMorePosts;
private FillFlowContainer content;
private ShowMoreButton showMore;
private CancellationTokenSource cancellationToken;
public ArticleListing(Action fetchMorePosts)
{
this.fetchMorePosts = fetchMorePosts;
}
[BackgroundDependencyLoader]
private void load()
{
@ -59,7 +66,7 @@ namespace osu.Game.Overlays.News.Displays
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Margin = new MarginPadding { Top = 15 },
Action = RequestMorePosts,
Action = fetchMorePosts,
Alpha = 0
}
}
@ -75,8 +82,6 @@ namespace osu.Game.Overlays.News.Displays
}, (cancellationToken = new CancellationTokenSource()).Token)
);
private CancellationTokenSource cancellationToken;
protected override void Dispose(bool isDisposing)
{
cancellationToken?.Cancel();

View File

@ -152,7 +152,7 @@ namespace osu.Game.Overlays
lastCursor = response.Cursor;
sidebar.Metadata.Value = response.SidebarMetadata;
var listing = new ArticleListing { RequestMorePosts = getMorePosts };
var listing = new ArticleListing(getMorePosts);
listing.AddPosts(response.NewsPosts, response.Cursor != null);
LoadDisplay(listing);
});