1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-15 18:13:09 +08:00

Add support for deleted comments with message

This commit is contained in:
Andrei Zavatski 2019-10-15 12:07:01 +03:00
parent 213f00556d
commit 96e31b9cca
2 changed files with 18 additions and 13 deletions

View File

@ -70,13 +70,9 @@ namespace osu.Game.Online.API.Requests.Responses
public bool IsDeleted => DeletedAt.HasValue; public bool IsDeleted => DeletedAt.HasValue;
public string GetMessage() public bool HasMessage => !string.IsNullOrEmpty(MessageHtml);
{
if (IsDeleted)
return @"deleted";
return WebUtility.HtmlDecode(Regex.Replace(MessageHtml, @"<(.|\n)*?>", string.Empty)); public string GetMessage => HasMessage ? WebUtility.HtmlDecode(Regex.Replace(MessageHtml, @"<(.|\n)*?>", string.Empty)) : string.Empty;
}
public int DeletedChildrenCount => ChildComments.Count(c => c.IsDeleted); public int DeletedChildrenCount => ChildComments.Count(c => c.IsDeleted);
} }

View File

@ -198,12 +198,13 @@ namespace osu.Game.Overlays.Comments
}); });
} }
if (!comment.IsDeleted) if (comment.HasMessage)
{ {
var formattedSource = MessageFormatter.FormatText(comment.GetMessage()); var formattedSource = MessageFormatter.FormatText(comment.GetMessage);
message.AddLinks(formattedSource.Text, formattedSource.Links); message.AddLinks(formattedSource.Text, formattedSource.Links);
} }
else
if (comment.IsDeleted)
{ {
content.FadeColour(OsuColour.Gray(0.5f)); content.FadeColour(OsuColour.Gray(0.5f));
votePill.Hide(); votePill.Hide();
@ -297,13 +298,13 @@ namespace osu.Game.Overlays.Comments
private class ParentUsername : FillFlowContainer, IHasTooltip private class ParentUsername : FillFlowContainer, IHasTooltip
{ {
public string TooltipText => comment.ParentComment?.GetMessage() ?? ""; public string TooltipText => getParentMessage();
private readonly Comment comment; private readonly Comment parentComment;
public ParentUsername(Comment comment) public ParentUsername(Comment comment)
{ {
this.comment = comment; parentComment = comment.ParentComment;
AutoSizeAxes = Axes.Both; AutoSizeAxes = Axes.Both;
Direction = FillDirection.Horizontal; Direction = FillDirection.Horizontal;
@ -319,10 +320,18 @@ namespace osu.Game.Overlays.Comments
new SpriteText new SpriteText
{ {
Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold, italics: true), Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold, italics: true),
Text = comment.ParentComment?.User?.Username ?? comment.ParentComment?.LegacyName Text = parentComment?.User?.Username ?? parentComment?.LegacyName
} }
}; };
} }
private string getParentMessage()
{
if (parentComment == null)
return string.Empty;
return parentComment.HasMessage ? parentComment.GetMessage : parentComment.IsDeleted ? @"deleted" : string.Empty;
}
} }
private class VotePill : CircularContainer private class VotePill : CircularContainer