Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/vs/workbench/contrib/comments/browser/commentNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,14 @@ export class CommentNode<T extends IRange | ICellRange> extends Disposable {
this._reactionsActionBar.clear();
this._reactionActions.clear();

const hasReactionHandler = this.commentService.hasReactionHandler(this.owner);
const reactions = this.comment.commentReactions?.filter(reaction => !!reaction.count) || [];

// Only create the container if there are reactions to show or if there's a reaction handler
if (reactions.length === 0 && !hasReactionHandler) {
return;
}
Comment on lines +420 to +422
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we shall create the container even if there is not reaction, but if there is a reaction handler
This way, adding the first reaction would still be possible

Suggested change
if (reactions.length === 0 && !hasReactionHandler) {
return;
}
if (!hasReactionHandler) {
return;
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The proposed change in this file already handles that case.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my bad, but the comment does not match (it says "or there is")


this._reactionActionsContainer = dom.append(commentDetailsContainer, dom.$('div.comment-reactions'));
this._reactionsActionBar.value = new ActionBar(this._reactionActionsContainer, {
actionViewItemProvider: (action, options) => {
Expand All @@ -432,8 +440,7 @@ export class CommentNode<T extends IRange | ICellRange> extends Disposable {
}
});

const hasReactionHandler = this.commentService.hasReactionHandler(this.owner);
this.comment.commentReactions?.filter(reaction => !!reaction.count).map(reaction => {
reactions.map(reaction => {
const action = this._reactionActions.add(new ReactionAction(`reaction.${reaction.label}`, `${reaction.label}`, reaction.hasReacted && (reaction.canEdit || hasReactionHandler) ? 'active' : '', (reaction.canEdit || hasReactionHandler), async () => {
try {
await this.commentService.toggleReaction(this.owner, this.resource, this.commentThread, this.comment, reaction);
Expand Down
Loading