mirror of
https://github.com/osukey/osukey.git
synced 2025-08-03 06:36:31 +09:00
Allow CommentsContainer refetch comments using a method
This commit is contained in:
@ -18,8 +18,8 @@ namespace osu.Game.Overlays.Comments
|
||||
{
|
||||
public class CommentsContainer : CompositeDrawable
|
||||
{
|
||||
private readonly CommentableType type;
|
||||
private readonly long id;
|
||||
private CommentableType type;
|
||||
private long id;
|
||||
|
||||
public readonly Bindable<CommentsSortCriteria> Sort = new Bindable<CommentsSortCriteria>();
|
||||
public readonly BindableBool ShowDeleted = new BindableBool();
|
||||
@ -39,11 +39,8 @@ namespace osu.Game.Overlays.Comments
|
||||
private readonly DeletedChildrenPlaceholder deletedChildrenPlaceholder;
|
||||
private readonly CommentsShowMoreButton moreButton;
|
||||
|
||||
public CommentsContainer(CommentableType type, long id)
|
||||
public CommentsContainer()
|
||||
{
|
||||
this.type = type;
|
||||
this.id = id;
|
||||
|
||||
RelativeSizeAxes = Axes.X;
|
||||
AutoSizeAxes = Axes.Y;
|
||||
AddRangeInternal(new Drawable[]
|
||||
@ -101,7 +98,8 @@ namespace osu.Game.Overlays.Comments
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Margin = new MarginPadding(5),
|
||||
Action = getComments
|
||||
Action = getComments,
|
||||
IsLoading = true,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -121,12 +119,24 @@ namespace osu.Game.Overlays.Comments
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
Sort.BindValueChanged(onSortChanged, true);
|
||||
Sort.BindValueChanged(_ => resetComments());
|
||||
base.LoadComplete();
|
||||
}
|
||||
|
||||
private void onSortChanged(ValueChangedEvent<CommentsSortCriteria> sort)
|
||||
/// <param name="type">The type of resource to get comments for.</param>
|
||||
/// <param name="id">The id of the resource to get comments for.</param>
|
||||
public void ShowComments(CommentableType type, long id)
|
||||
{
|
||||
this.type = type;
|
||||
this.id = id;
|
||||
Sort.TriggerChange();
|
||||
}
|
||||
|
||||
private void resetComments()
|
||||
{
|
||||
if (id == default)
|
||||
return;
|
||||
|
||||
clearComments();
|
||||
getComments();
|
||||
}
|
||||
@ -152,7 +162,7 @@ namespace osu.Game.Overlays.Comments
|
||||
{
|
||||
loadCancellation = new CancellationTokenSource();
|
||||
|
||||
FillFlowContainer page = new FillFlowContainer
|
||||
var page = new FillFlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
|
Reference in New Issue
Block a user