mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 08:49:59 +09:00
Parse child comments
This commit is contained in:
@ -9,8 +9,28 @@ namespace osu.Game.Online.API.Requests.Responses
|
||||
{
|
||||
public class APIComments
|
||||
{
|
||||
private List<Comment> comments;
|
||||
|
||||
[JsonProperty(@"comments")]
|
||||
public List<Comment> Comments { get; set; }
|
||||
public List<Comment> Comments
|
||||
{
|
||||
get => comments;
|
||||
set
|
||||
{
|
||||
comments = value;
|
||||
comments.ForEach(child =>
|
||||
{
|
||||
if (child.ParentId != null)
|
||||
{
|
||||
comments.ForEach(parent =>
|
||||
{
|
||||
if (parent.Id == child.ParentId)
|
||||
parent.ChildComments.Add(child);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
[JsonProperty(@"has_more")]
|
||||
public bool HasMore { get; set; }
|
||||
|
@ -4,6 +4,7 @@
|
||||
using Newtonsoft.Json;
|
||||
using osu.Game.Users;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace osu.Game.Online.API.Requests.Responses
|
||||
{
|
||||
@ -25,6 +26,8 @@ namespace osu.Game.Online.API.Requests.Responses
|
||||
}
|
||||
}
|
||||
|
||||
public List<Comment> ChildComments = new List<Comment>();
|
||||
|
||||
[JsonProperty(@"user_id")]
|
||||
public long UserId { get; set; }
|
||||
|
||||
|
@ -17,6 +17,8 @@ namespace osu.Game.Overlays.Comments
|
||||
{
|
||||
public class CommentsContainer : CompositeDrawable
|
||||
{
|
||||
private const float separator_height = 1.5f;
|
||||
|
||||
private readonly CommentableType type;
|
||||
private readonly long id;
|
||||
|
||||
@ -97,7 +99,7 @@ namespace osu.Game.Overlays.Comments
|
||||
new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = 1,
|
||||
Height = separator_height,
|
||||
Child = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
|
@ -17,14 +17,23 @@ namespace osu.Game.Overlays.Comments
|
||||
{
|
||||
private const int avatar_size = 40;
|
||||
private const int margin = 10;
|
||||
private const int child_margin = 20;
|
||||
|
||||
public DrawableComment(Comment comment)
|
||||
{
|
||||
LinkFlowContainer username;
|
||||
FillFlowContainer childCommentsContainer;
|
||||
|
||||
RelativeSizeAxes = Axes.X;
|
||||
AutoSizeAxes = Axes.Y;
|
||||
InternalChild = new GridContainer
|
||||
InternalChild = new FillFlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Direction = FillDirection.Vertical,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new GridContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
@ -86,9 +95,24 @@ namespace osu.Game.Overlays.Comments
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
childCommentsContainer = new FillFlowContainer
|
||||
{
|
||||
Margin = new MarginPadding { Left = child_margin },
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Direction = FillDirection.Vertical
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
username.AddUserLink(comment.User);
|
||||
|
||||
comment.ChildComments.ForEach(c =>
|
||||
{
|
||||
if (!c.IsDeleted)
|
||||
childCommentsContainer.Add(new DrawableComment(c));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user