Skip to content

Commit 01293da

Browse files
committed
Use outdated property on review thread
Part of #8401
1 parent 0d19b45 commit 01293da

File tree

5 files changed

+12
-8
lines changed

5 files changed

+12
-8
lines changed

src/common/comment.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ export interface IComment {
6565
graphNodeId: string;
6666
reactions?: Reaction[];
6767
isResolved?: boolean;
68+
isOutdated?: boolean;
6869
}
6970

7071
const COPILOT_AUTHOR = {

src/github/pullRequestModel.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ export class PullRequestModel extends IssueModel<PullRequest> implements IPullRe
647647
});
648648

649649
const { comments, databaseId } = data!.deletePullRequestReview.pullRequestReview;
650-
const deletedReviewComments = comments.nodes.map(comment => parseGraphQLComment(comment, false, this.githubRepository));
650+
const deletedReviewComments = comments.nodes.map(comment => parseGraphQLComment(comment, false, false, this.githubRepository));
651651

652652
// Update local state: remove all draft comments (and their threads if emptied) that belonged to the deleted review
653653
const deletedCommentIds = new Set(deletedReviewComments.map(c => c.id));
@@ -822,7 +822,7 @@ export class PullRequestModel extends IssueModel<PullRequest> implements IPullRe
822822
}
823823

824824
const { comment } = data.addPullRequestReviewComment;
825-
const newComment = parseGraphQLComment(comment, false, this.githubRepository);
825+
const newComment = parseGraphQLComment(comment, false, false, this.githubRepository);
826826

827827
if (isSingleComment) {
828828
newComment.isDraft = false;
@@ -1024,6 +1024,7 @@ export class PullRequestModel extends IssueModel<PullRequest> implements IPullRe
10241024
const newComment = parseGraphQLComment(
10251025
data.updatePullRequestReviewComment.pullRequestReviewComment,
10261026
!!comment.isResolved,
1027+
!!comment.isOutdated,
10271028
this.githubRepository
10281029
);
10291030
if (threadWithComment) {
@@ -1401,7 +1402,7 @@ export class PullRequestModel extends IssueModel<PullRequest> implements IPullRe
14011402

14021403
this.setReviewThreadCacheFromRaw(raw);
14031404

1404-
this.comments = raw.map(node => node.comments.nodes.map(comment => parseGraphQLComment(comment, node.isResolved, this.githubRepository), remote))
1405+
this.comments = raw.map(node => node.comments.nodes.map(comment => parseGraphQLComment(comment, node.isResolved, node.isOutdated, this.githubRepository), remote))
14051406
.reduce((prev, curr) => prev.concat(curr), [])
14061407
.sort((a: IComment, b: IComment) => {
14071408
return a.createdAt > b.createdAt ? 1 : -1;

src/github/utils.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -521,12 +521,12 @@ export function parseGraphQLReviewThread(thread: GraphQL.ReviewThread, githubRep
521521
originalEndLine: thread.originalLine,
522522
diffSide: thread.diffSide,
523523
isOutdated: thread.isOutdated,
524-
comments: thread.comments.nodes.map(comment => parseGraphQLComment(comment, thread.isResolved, githubRepository)),
524+
comments: thread.comments.nodes.map(comment => parseGraphQLComment(comment, thread.isResolved, thread.isOutdated, githubRepository)),
525525
subjectType: thread.subjectType ?? SubjectType.LINE
526526
};
527527
}
528528

529-
export function parseGraphQLComment(comment: GraphQL.ReviewComment, isResolved: boolean, githubRepository: GitHubRepository): IComment {
529+
export function parseGraphQLComment(comment: GraphQL.ReviewComment, isResolved: boolean, isOutdated: boolean, githubRepository: GitHubRepository): IComment {
530530
const specialAuthor = COPILOT_ACCOUNTS[comment.author?.login ?? ''];
531531
const c: IComment = {
532532
id: comment.databaseId,
@@ -551,6 +551,7 @@ export function parseGraphQLComment(comment: GraphQL.ReviewComment, isResolved:
551551
inReplyToId: comment.replyTo && comment.replyTo.databaseId,
552552
reactions: parseGraphQLReaction(comment.reactionGroups),
553553
isResolved,
554+
isOutdated
554555
};
555556

556557
const diffHunks = parseCommentDiffHunk(c);
@@ -573,7 +574,7 @@ export function parseGraphQlIssueComment(comment: GraphQL.IssueComment, githubRe
573574
htmlUrl: comment.url,
574575
graphNodeId: comment.id,
575576
diffHunk: '',
576-
reactions: parseGraphQLReaction(comment.reactionGroups),
577+
reactions: parseGraphQLReaction(comment.reactionGroups)
577578
};
578579
}
579580

@@ -1030,7 +1031,7 @@ export function parseGraphQLReviewEvent(
10301031
): Common.ReviewEvent {
10311032
return {
10321033
event: Common.EventType.Reviewed,
1033-
comments: review.comments.nodes.map(comment => parseGraphQLComment(comment, false, githubRepository)).filter(c => !c.inReplyToId),
1034+
comments: review.comments.nodes.map(comment => parseGraphQLComment(comment, false, false, githubRepository)).filter(c => !c.inReplyToId),
10341035
submittedAt: review.submittedAt,
10351036
body: review.body,
10361037
bodyHTML: review.bodyHTML,

src/test/view/reviewCommentController.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ describe('ReviewCommentController', function () {
205205
createdAt: '',
206206
htmlUrl: '',
207207
graphNodeId: '',
208+
isOutdated: false
208209
}
209210
],
210211
subjectType: SubjectType.LINE

src/view/reviewManager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -976,7 +976,7 @@ export class ReviewManager extends Disposable {
976976
this._reviewModel.localFileChanges = await this.getLocalChangeNodes(pr, contentChanges);
977977
await Promise.all([pr.initializeReviewThreadCacheAndReviewComments(), pr.initializePullRequestFileViewState()]);
978978
this._folderRepoManager.setFileViewedContext();
979-
const outdatedComments = pr.comments.filter(comment => !comment.position);
979+
const outdatedComments = pr.comments.filter(comment => comment.isOutdated || !comment.position);
980980

981981
const commitsGroup = groupBy(outdatedComments, comment => comment.originalCommitId!);
982982
const obsoleteFileChanges: (GitFileChangeNode | RemoteFileChangeNode)[] = [];

0 commit comments

Comments
 (0)