Parse child comments

This commit is contained in:
Andrei Zavatski
2019-10-08 15:39:03 +03:00
parent 2564214a72
commit 451a7342ce
4 changed files with 92 additions and 43 deletions

View File

@ -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; }

View File

@ -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; }