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