1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-18 02:47:19 +08:00

Fix incorrect algorithm for comment tree creation

Can cause one comment to be redrawn multiple times
This commit is contained in:
Andrei Zavatski 2020-02-10 23:57:48 +03:00
parent d20a860879
commit 15b4e3386f

View File

@ -62,24 +62,26 @@ namespace osu.Game.Overlays.Comments
return;
}
foreach (var comment in commentBundle.Comments)
commentBundle.Comments.ForEach(c =>
{
var drawableComment = createDrawableComment(comment);
if (c.IsTopLevel)
flow.Add(createCommentWithReplies(c, commentBundle));
});
}
var children = commentBundle.Comments.Where(c => c.ParentId == comment.Id);
private DrawableComment createCommentWithReplies(Comment comment, CommentBundle commentBundle)
{
var drawableComment = createDrawableComment(comment);
if (children.Any())
{
children.ForEach(c =>
{
c.ParentComment = comment;
});
drawableComment.OnLoadComplete += loaded => ((DrawableComment)loaded).AddReplies(children.Select(createDrawableComment));
}
var replies = commentBundle.Comments.Where(c => c.ParentId == comment.Id);
if (comment.IsTopLevel)
flow.Add(drawableComment);
if (replies.Any())
{
replies.ForEach(c => c.ParentComment = comment);
drawableComment.OnLoadComplete += _ => drawableComment.AddReplies(replies.Select(reply => createCommentWithReplies(reply, commentBundle)));
}
return drawableComment;
}
private void onCommentRepliesRequested(DrawableComment drawableComment, int page)