mirror of https://github.com/ppy/osu
Add support for deleted comments with message
This commit is contained in:
parent
213f00556d
commit
96e31b9cca
|
@ -70,13 +70,9 @@ public class Comment
|
|||
|
||||
public bool IsDeleted => DeletedAt.HasValue;
|
||||
|
||||
public string GetMessage()
|
||||
{
|
||||
if (IsDeleted)
|
||||
return @"deleted";
|
||||
public bool HasMessage => !string.IsNullOrEmpty(MessageHtml);
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -198,12 +198,13 @@ public DrawableComment(Comment comment)
|
|||
});
|
||||
}
|
||||
|
||||
if (!comment.IsDeleted)
|
||||
if (comment.HasMessage)
|
||||
{
|
||||
var formattedSource = MessageFormatter.FormatText(comment.GetMessage());
|
||||
var formattedSource = MessageFormatter.FormatText(comment.GetMessage);
|
||||
message.AddLinks(formattedSource.Text, formattedSource.Links);
|
||||
}
|
||||
else
|
||||
|
||||
if (comment.IsDeleted)
|
||||
{
|
||||
content.FadeColour(OsuColour.Gray(0.5f));
|
||||
votePill.Hide();
|
||||
|
@ -297,13 +298,13 @@ protected override void OnExpandedChanged(ValueChangedEvent<bool> expanded)
|
|||
|
||||
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)
|
||||
{
|
||||
this.comment = comment;
|
||||
parentComment = comment.ParentComment;
|
||||
|
||||
AutoSizeAxes = Axes.Both;
|
||||
Direction = FillDirection.Horizontal;
|
||||
|
@ -319,10 +320,18 @@ public ParentUsername(Comment comment)
|
|||
new SpriteText
|
||||
{
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue