osu/osu.Game/Online/API/Requests/Responses/CommentBundle.cs

82 lines
2.1 KiB
C#
Raw Normal View History

2019-10-07 13:48:05 +00:00
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using Newtonsoft.Json;
using osu.Game.Users;
using System.Collections.Generic;
namespace osu.Game.Online.API.Requests.Responses
{
2019-10-15 08:20:06 +00:00
public class CommentBundle
2019-10-07 13:48:05 +00:00
{
[JsonProperty(@"comments")]
public List<Comment> Comments { get; set; }
2019-10-07 13:48:05 +00:00
[JsonProperty(@"has_more")]
public bool HasMore { get; set; }
[JsonProperty(@"has_more_id")]
public long? HasMoreId { get; set; }
2019-10-07 13:48:05 +00:00
[JsonProperty(@"user_follow")]
public bool UserFollow { get; set; }
[JsonProperty(@"included_comments")]
public List<Comment> IncludedComments { get; set; }
2020-01-29 03:44:39 +00:00
private List<long> userVotes;
2019-10-17 09:35:12 +00:00
[JsonProperty(@"user_votes")]
2020-01-29 03:44:39 +00:00
public List<long> UserVotes
2019-10-17 09:35:12 +00:00
{
2020-01-29 03:44:39 +00:00
get => userVotes;
set
2019-10-17 09:35:12 +00:00
{
2020-01-29 03:44:39 +00:00
userVotes = value;
2020-01-29 21:53:05 +00:00
Comments.ForEach(c => c.IsVoted = value.Contains(c.Id));
IncludedComments.ForEach(c => c.IsVoted = value.Contains(c.Id));
2020-01-29 03:44:39 +00:00
}
2019-10-17 09:35:12 +00:00
}
private List<User> users;
2019-10-07 13:48:05 +00:00
[JsonProperty(@"users")]
public List<User> Users
{
get => users;
set
{
users = value;
value.ForEach(u =>
{
Comments.ForEach(c =>
{
if (c.UserId == u.Id)
c.User = u;
2019-10-09 08:32:17 +00:00
if (c.EditedById == u.Id)
c.EditedUser = u;
});
IncludedComments.ForEach(c =>
{
if (c.UserId == u.Id)
c.User = u;
if (c.EditedById == u.Id)
c.EditedUser = u;
});
});
}
}
2019-10-07 13:48:05 +00:00
[JsonProperty(@"total")]
public int Total { get; set; }
[JsonProperty(@"top_level_count")]
public int TopLevelCount { get; set; }
}
}