mirror of
https://github.com/ppy/osu
synced 2025-02-22 13:37:08 +00:00
Simplify parent comment assignment
This commit is contained in:
parent
483bbac6fd
commit
b1b2e4a041
@ -63,9 +63,10 @@ namespace osu.Game.Overlays.Comments
|
||||
createBaseTree(commentBundle.Comments);
|
||||
}
|
||||
|
||||
private readonly Dictionary<long, Comment> nodeDictionary = new Dictionary<long, Comment>();
|
||||
|
||||
private void createBaseTree(List<Comment> comments)
|
||||
{
|
||||
var nodeDictionary = new Dictionary<long, Comment>();
|
||||
var topLevelNodes = new List<Comment>();
|
||||
var orphanedNodes = new List<Comment>();
|
||||
|
||||
@ -82,7 +83,6 @@ namespace osu.Game.Overlays.Comments
|
||||
{
|
||||
if (orphan.ParentId == comment.Id)
|
||||
{
|
||||
orphan.ParentComment = comment;
|
||||
comment.ChildComments.Add(orphan);
|
||||
orphanedNodes.Remove(orphan);
|
||||
}
|
||||
@ -93,10 +93,7 @@ namespace osu.Game.Overlays.Comments
|
||||
continue;
|
||||
|
||||
if (nodeDictionary.ContainsKey(comment.ParentId.Value))
|
||||
{
|
||||
comment.ParentComment = nodeDictionary[comment.ParentId.Value];
|
||||
nodeDictionary[comment.ParentId.Value].ChildComments.Add(comment);
|
||||
}
|
||||
else
|
||||
orphanedNodes.Add(comment);
|
||||
}
|
||||
@ -107,6 +104,9 @@ namespace osu.Game.Overlays.Comments
|
||||
|
||||
private DrawableComment createCommentWithReplies(Comment comment)
|
||||
{
|
||||
if (comment.ParentId.HasValue)
|
||||
comment.ParentComment = nodeDictionary[comment.ParentId.Value];
|
||||
|
||||
var drawableComment = createDrawableComment(comment);
|
||||
|
||||
var replies = comment.ChildComments;
|
||||
|
Loading…
Reference in New Issue
Block a user