mirror of
https://github.com/osukey/osukey.git
synced 2025-05-17 19:47:33 +09: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);
|
createBaseTree(commentBundle.Comments);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private readonly Dictionary<long, Comment> nodeDictionary = new Dictionary<long, Comment>();
|
||||||
|
|
||||||
private void createBaseTree(List<Comment> comments)
|
private void createBaseTree(List<Comment> comments)
|
||||||
{
|
{
|
||||||
var nodeDictionary = new Dictionary<long, Comment>();
|
|
||||||
var topLevelNodes = new List<Comment>();
|
var topLevelNodes = new List<Comment>();
|
||||||
var orphanedNodes = new List<Comment>();
|
var orphanedNodes = new List<Comment>();
|
||||||
|
|
||||||
@ -82,7 +83,6 @@ namespace osu.Game.Overlays.Comments
|
|||||||
{
|
{
|
||||||
if (orphan.ParentId == comment.Id)
|
if (orphan.ParentId == comment.Id)
|
||||||
{
|
{
|
||||||
orphan.ParentComment = comment;
|
|
||||||
comment.ChildComments.Add(orphan);
|
comment.ChildComments.Add(orphan);
|
||||||
orphanedNodes.Remove(orphan);
|
orphanedNodes.Remove(orphan);
|
||||||
}
|
}
|
||||||
@ -93,10 +93,7 @@ namespace osu.Game.Overlays.Comments
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (nodeDictionary.ContainsKey(comment.ParentId.Value))
|
if (nodeDictionary.ContainsKey(comment.ParentId.Value))
|
||||||
{
|
|
||||||
comment.ParentComment = nodeDictionary[comment.ParentId.Value];
|
|
||||||
nodeDictionary[comment.ParentId.Value].ChildComments.Add(comment);
|
nodeDictionary[comment.ParentId.Value].ChildComments.Add(comment);
|
||||||
}
|
|
||||||
else
|
else
|
||||||
orphanedNodes.Add(comment);
|
orphanedNodes.Add(comment);
|
||||||
}
|
}
|
||||||
@ -107,6 +104,9 @@ namespace osu.Game.Overlays.Comments
|
|||||||
|
|
||||||
private DrawableComment createCommentWithReplies(Comment comment)
|
private DrawableComment createCommentWithReplies(Comment comment)
|
||||||
{
|
{
|
||||||
|
if (comment.ParentId.HasValue)
|
||||||
|
comment.ParentComment = nodeDictionary[comment.ParentId.Value];
|
||||||
|
|
||||||
var drawableComment = createDrawableComment(comment);
|
var drawableComment = createDrawableComment(comment);
|
||||||
|
|
||||||
var replies = comment.ChildComments;
|
var replies = comment.ChildComments;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user