diff --git a/osu.Game/Overlays/Comments/CommentsPage.cs b/osu.Game/Overlays/Comments/CommentsPage.cs index ebce2177cf..cab3e49f62 100644 --- a/osu.Game/Overlays/Comments/CommentsPage.cs +++ b/osu.Game/Overlays/Comments/CommentsPage.cs @@ -89,7 +89,7 @@ namespace osu.Game.Overlays.Comments } // No need to find parent for top-level comment - if (comment.IsTopLevel) + if (!comment.ParentId.HasValue) continue; if (nodeDictionary.ContainsKey(comment.ParentId.Value)) @@ -112,7 +112,7 @@ namespace osu.Game.Overlays.Comments var replies = comment.ChildComments; if (replies.Any()) - drawableComment.InitialReplies.AddRange(replies.Select(createCommentWithReplies)); + drawableComment.Replies.AddRange(replies.Select(createCommentWithReplies)); return drawableComment; } @@ -139,7 +139,7 @@ namespace osu.Game.Overlays.Comments uniqueComments.ForEach(c => c.ParentComment = drawableComment.Comment); - drawableComment.AddReplies(uniqueComments.Select(createDrawableComment)); + drawableComment.Replies.AddRange(uniqueComments.Select(createDrawableComment)); } private DrawableComment createDrawableComment(Comment comment) => new DrawableComment(comment) diff --git a/osu.Game/Overlays/Comments/DrawableComment.cs b/osu.Game/Overlays/Comments/DrawableComment.cs index 8bc989761e..7774921f00 100644 --- a/osu.Game/Overlays/Comments/DrawableComment.cs +++ b/osu.Game/Overlays/Comments/DrawableComment.cs @@ -37,10 +37,7 @@ namespace osu.Game.Overlays.Comments public readonly Bindable Sort = new Bindable(); private readonly Dictionary loadedReplies = new Dictionary(); - /// - /// s which will be added to this as replies on initial load. - /// - public readonly List InitialReplies = new List(); + public readonly BindableList Replies = new BindableList(); private readonly BindableBool childrenExpanded = new BindableBool(true); @@ -272,8 +269,10 @@ namespace osu.Game.Overlays.Comments }); } - if (InitialReplies.Any()) - AddReplies(InitialReplies); + Replies.ItemsAdded += onRepliesAdded; + + if (Replies.Any()) + onRepliesAdded(Replies); } protected override void LoadComplete() @@ -292,11 +291,8 @@ namespace osu.Game.Overlays.Comments public bool ContainsReply(long replyId) => loadedReplies.ContainsKey(replyId); - public void AddReplies(IEnumerable replies) + private void onRepliesAdded(IEnumerable replies) { - if (LoadState == LoadState.NotLoaded) - throw new NotSupportedException($@"Can't use {nameof(AddReplies)} when not loaded."); - var page = createRepliesPage(replies); if (LoadState == LoadState.Loading)