Skip to content

Commit

Permalink
Review state can be undefined (#6094)
Browse files Browse the repository at this point in the history
Fixes #6090
  • Loading branch information
alexr00 authored Jul 18, 2024
1 parent df10772 commit 9cd8269
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/common/timelineEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export interface ReviewEvent {
htmlUrl: string;
user: IAccount;
authorAssociation: string;
state: 'COMMENTED' | 'APPROVED' | 'CHANGES_REQUESTED' | 'PENDING' | 'REQUESTED';
state?: 'COMMENTED' | 'APPROVED' | 'CHANGES_REQUESTED' | 'PENDING' | 'REQUESTED';
}

export interface CommitEvent {
Expand Down
2 changes: 1 addition & 1 deletion src/github/activityBarViewProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ export class PullRequestViewProvider extends WebviewViewBase implements vscode.W
}

private updateReviewers(review?: CommonReviewEvent): void {
if (review) {
if (review && review.state) {
const existingReviewer = this._existingReviewers.find(
reviewer => review.user.login === reviewerId(reviewer.reviewer),
);
Expand Down
2 changes: 1 addition & 1 deletion src/github/pullRequestModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1271,7 +1271,7 @@ export class PullRequestModel extends IssueModel<PullRequest> implements IPullRe

});

const pendingReview = reviewEvents.filter(r => r.state.toLowerCase() === 'pending')[0];
const pendingReview = reviewEvents.filter(r => r.state?.toLowerCase() === 'pending')[0];
if (pendingReview) {
// Ensures that pending comments made in reply to other reviews are included for the pending review
pendingReview.comments = reviewComments.filter(c => c.isDraft);
Expand Down
2 changes: 1 addition & 1 deletion src/github/pullRequestOverview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ export class PullRequestOverviewPanel extends IssueOverviewPanel<PullRequestMode
}

private updateReviewers(review?: CommonReviewEvent): void {
if (review) {
if (review && review.state) {
const existingReviewer = this._existingReviewers.find(
reviewer => review.user.login === (reviewer.reviewer as IAccount).login,
);
Expand Down
7 changes: 4 additions & 3 deletions src/github/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1183,12 +1183,13 @@ export function parseReviewers(
seen.set(author.login, true);

for (let i = reviewEvents.length - 1; i >= 0; i--) {
const reviewer = reviewEvents[i].user;
if (!seen.get(reviewer.login)) {
const reviewEvent = reviewEvents[i];
const reviewer = reviewEvent.user;
if (reviewEvent.state && !seen.get(reviewer.login)) {
seen.set(reviewer.login, true);
reviewers.push({
reviewer: reviewer,
state: reviewEvents[i].state,
state: reviewEvent.state,
});
}
}
Expand Down

0 comments on commit 9cd8269

Please sign in to comment.