Skip to content

Commit e12c0af

Browse files
committed
Fix display of delete button on comments
1 parent fc3c7d0 commit e12c0af

3 files changed

Lines changed: 11 additions & 1 deletion

File tree

src/helpers.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ export const mergeThread = (local: vscode.CommentThread, remote: any): boolean =
108108
(a.timestamp ? Number(a.timestamp) : 0) - (b.timestamp ? Number(b.timestamp) : 0),
109109
);
110110

111+
// mark all merged comments as deletable, except for the first one
112+
mergedComments.slice(1).forEach((comment) => (comment.contextValue = 'canDelete'));
113+
111114
// assigned unique and sorted comments to current thread
112115
local.comments = mergedComments;
113116
return merged;

src/models/noteComment.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,6 @@ export class NoteComment implements vscode.Comment {
2424
} else {
2525
this.timestamp = new Date();
2626
}
27+
this.contextValue = contextValue;
2728
}
2829
}

src/persistence/serialization/deserializer.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export class Deserializer {
3535
{ name: comment.author },
3636
parent,
3737
deserializedReactions,
38-
undefined,
38+
parent && parent.comments.length ? 'canDelete' : undefined,
3939
comment.timestamp,
4040
);
4141
return newComment;
@@ -61,6 +61,12 @@ export class Deserializer {
6161
deserializedComments.push(this.deserializeComment(comment, newThread));
6262
});
6363
newThread.comments = deserializedComments;
64+
65+
// mark all comments as deletable, except for the first one
66+
newThread.comments
67+
.slice(1)
68+
.forEach((comment) => (comment.contextValue = 'canDelete'));
69+
6470
return newThread;
6571
}
6672

0 commit comments

Comments
 (0)