mirror of
https://github.com/osukey/osukey.git
synced 2025-05-17 03:27:21 +09:00
Use linq expression to count deleted comments
This commit is contained in:
parent
b84c9dfd84
commit
0fd6b0c852
@ -78,18 +78,6 @@ namespace osu.Game.Online.API.Requests.Responses
|
|||||||
return WebUtility.HtmlDecode(Regex.Replace(MessageHtml, @"<(.|\n)*?>", string.Empty));
|
return WebUtility.HtmlDecode(Regex.Replace(MessageHtml, @"<(.|\n)*?>", string.Empty));
|
||||||
}
|
}
|
||||||
|
|
||||||
public int GetDeletedChildrenCount()
|
public int GetDeletedChildrenCount => ChildComments.Select(c => c.IsDeleted).Where(c => c).Count();
|
||||||
{
|
|
||||||
int count = 0;
|
|
||||||
|
|
||||||
if (ChildComments.Any())
|
|
||||||
ChildComments.ForEach(child =>
|
|
||||||
{
|
|
||||||
if (child.IsDeleted)
|
|
||||||
count++;
|
|
||||||
});
|
|
||||||
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ using osu.Framework.Graphics.Shapes;
|
|||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Online.API.Requests.Responses;
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Comments
|
namespace osu.Game.Overlays.Comments
|
||||||
{
|
{
|
||||||
@ -162,13 +163,7 @@ namespace osu.Game.Overlays.Comments
|
|||||||
{
|
{
|
||||||
content.Add(loaded);
|
content.Add(loaded);
|
||||||
|
|
||||||
int deletedComments = 0;
|
int deletedComments = response.Comments.Select(c => c.IsDeleted && c.IsTopLevel).Where(c => c).Count();
|
||||||
|
|
||||||
response.Comments.ForEach(comment =>
|
|
||||||
{
|
|
||||||
if (comment.IsDeleted && comment.IsTopLevel)
|
|
||||||
deletedComments++;
|
|
||||||
});
|
|
||||||
|
|
||||||
deletedChildrenPlaceholder.DeletedCount.Value = initial ? deletedComments : deletedChildrenPlaceholder.DeletedCount.Value + deletedComments;
|
deletedChildrenPlaceholder.DeletedCount.Value = initial ? deletedComments : deletedChildrenPlaceholder.DeletedCount.Value + deletedComments;
|
||||||
|
|
||||||
|
@ -180,7 +180,7 @@ namespace osu.Game.Overlays.Comments
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
deletedChildrenPlaceholder.DeletedCount.Value = comment.GetDeletedChildrenCount();
|
deletedChildrenPlaceholder.DeletedCount.Value = comment.GetDeletedChildrenCount;
|
||||||
|
|
||||||
if (comment.UserId.HasValue)
|
if (comment.UserId.HasValue)
|
||||||
username.AddUserLink(comment.User);
|
username.AddUserLink(comment.User);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user