mirror of
https://github.com/osukey/osukey.git
synced 2025-05-20 04:57:38 +09:00
Pass fetch more action in via ctor to avoid potential nullref
This commit is contained in:
parent
9947867e84
commit
735e7b9c74
@ -19,11 +19,18 @@ namespace osu.Game.Overlays.News.Displays
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class ArticleListing : CompositeDrawable
|
public class ArticleListing : CompositeDrawable
|
||||||
{
|
{
|
||||||
public Action RequestMorePosts;
|
private readonly Action fetchMorePosts;
|
||||||
|
|
||||||
private FillFlowContainer content;
|
private FillFlowContainer content;
|
||||||
private ShowMoreButton showMore;
|
private ShowMoreButton showMore;
|
||||||
|
|
||||||
|
private CancellationTokenSource cancellationToken;
|
||||||
|
|
||||||
|
public ArticleListing(Action fetchMorePosts)
|
||||||
|
{
|
||||||
|
this.fetchMorePosts = fetchMorePosts;
|
||||||
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
@ -59,7 +66,7 @@ namespace osu.Game.Overlays.News.Displays
|
|||||||
Anchor = Anchor.TopCentre,
|
Anchor = Anchor.TopCentre,
|
||||||
Origin = Anchor.TopCentre,
|
Origin = Anchor.TopCentre,
|
||||||
Margin = new MarginPadding { Top = 15 },
|
Margin = new MarginPadding { Top = 15 },
|
||||||
Action = RequestMorePosts,
|
Action = fetchMorePosts,
|
||||||
Alpha = 0
|
Alpha = 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -75,8 +82,6 @@ namespace osu.Game.Overlays.News.Displays
|
|||||||
}, (cancellationToken = new CancellationTokenSource()).Token)
|
}, (cancellationToken = new CancellationTokenSource()).Token)
|
||||||
);
|
);
|
||||||
|
|
||||||
private CancellationTokenSource cancellationToken;
|
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
protected override void Dispose(bool isDisposing)
|
||||||
{
|
{
|
||||||
cancellationToken?.Cancel();
|
cancellationToken?.Cancel();
|
||||||
|
@ -152,7 +152,7 @@ namespace osu.Game.Overlays
|
|||||||
lastCursor = response.Cursor;
|
lastCursor = response.Cursor;
|
||||||
sidebar.Metadata.Value = response.SidebarMetadata;
|
sidebar.Metadata.Value = response.SidebarMetadata;
|
||||||
|
|
||||||
var listing = new ArticleListing { RequestMorePosts = getMorePosts };
|
var listing = new ArticleListing(getMorePosts);
|
||||||
listing.AddPosts(response.NewsPosts, response.Cursor != null);
|
listing.AddPosts(response.NewsPosts, response.Cursor != null);
|
||||||
LoadDisplay(listing);
|
LoadDisplay(listing);
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user