1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 09:32:55 +08:00

Include commentable object metadata in comments

This commit is contained in:
Salman Ahmed 2024-02-14 03:46:19 +03:00
parent c4e358044a
commit 72c6134dbf
3 changed files with 8 additions and 6 deletions

View File

@ -301,7 +301,7 @@ namespace osu.Game.Overlays.Comments
void addNewComment(Comment comment)
{
var drawableComment = GetDrawableComment(comment);
var drawableComment = GetDrawableComment(comment, bundle.CommentableMeta);
if (comment.ParentId == null)
{
@ -333,7 +333,7 @@ namespace osu.Game.Overlays.Comments
if (CommentDictionary.ContainsKey(comment.Id))
continue;
topLevelComments.Add(GetDrawableComment(comment));
topLevelComments.Add(GetDrawableComment(comment, bundle.CommentableMeta));
}
if (topLevelComments.Any())
@ -351,12 +351,12 @@ namespace osu.Game.Overlays.Comments
}
}
public DrawableComment GetDrawableComment(Comment comment)
public DrawableComment GetDrawableComment(Comment comment, IReadOnlyList<CommentableMeta> meta)
{
if (CommentDictionary.TryGetValue(comment.Id, out var existing))
return existing;
return CommentDictionary[comment.Id] = new DrawableComment(comment)
return CommentDictionary[comment.Id] = new DrawableComment(comment, meta)
{
ShowDeleted = { BindTarget = ShowDeleted },
Sort = { BindTarget = Sort },

View File

@ -39,6 +39,7 @@ namespace osu.Game.Overlays.Comments
public Action<DrawableComment, int> RepliesRequested = null!;
public readonly Comment Comment;
public readonly IReadOnlyList<CommentableMeta> Meta;
public readonly BindableBool ShowDeleted = new BindableBool();
public readonly Bindable<CommentsSortCriteria> Sort = new Bindable<CommentsSortCriteria>();
@ -87,9 +88,10 @@ namespace osu.Game.Overlays.Comments
[Resolved]
private OnScreenDisplay? onScreenDisplay { get; set; }
public DrawableComment(Comment comment)
public DrawableComment(Comment comment, IReadOnlyList<CommentableMeta> meta)
{
Comment = comment;
Meta = meta;
}
[BackgroundDependencyLoader]

View File

@ -60,7 +60,7 @@ namespace osu.Game.Overlays.Comments
foreach (var comment in cb.Comments)
comment.ParentComment = parentComment;
var drawables = cb.Comments.Select(commentsContainer.GetDrawableComment).ToArray();
var drawables = cb.Comments.Select(c => commentsContainer.GetDrawableComment(c, cb.CommentableMeta)).ToArray();
OnPost?.Invoke(drawables);
OnCancel!.Invoke();