Skip to content

Commit 23b1f05

Browse files
committed
Adopt comment thread state API proposal
Part of microsoft/vscode#127473
1 parent 7dc3900 commit 23b1f05

File tree

5 files changed

+31
-7
lines changed

5 files changed

+31
-7
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"url": "https://github.com/Microsoft/vscode-pull-request-github/issues"
1212
},
1313
"enabledApiProposals": [
14-
"tokenInformation"
14+
"tokenInformation",
15+
"commentsResolvedState"
1516
],
1617
"version": "0.40.0",
1718
"publisher": "GitHub",
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
declare module 'vscode' {
7+
8+
// https://github.com/microsoft/vscode/issues/127473
9+
10+
export enum CommentThreadState {
11+
Unresolved = 0,
12+
Resolved = 1
13+
}
14+
15+
// TODO@API doc
16+
export interface CommentThread {
17+
state?: CommentThreadState;
18+
}
19+
}

src/github/prComment.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export interface GHPRCommentThread extends vscode.CommentThread {
4141
/**
4242
* Whether the thread has been marked as resolved.
4343
*/
44-
isResolved: boolean;
44+
state: vscode.CommentThreadState;
4545

4646
dispose: () => void;
4747
}

src/github/utils.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export function createVSCodeCommentThreadForReviewThread(
4747
(vscodeThread as GHPRCommentThread).gitHubThreadId = thread.id;
4848

4949
vscodeThread.comments = thread.comments.map(comment => new GHPRComment(comment, vscodeThread as GHPRCommentThread));
50-
(vscodeThread as GHPRCommentThread).isResolved = thread.isResolved;
50+
vscodeThread.state = isResolvedToResolvedState(thread.isResolved);
5151

5252
if (thread.viewerCanResolve && !thread.isResolved) {
5353
vscodeThread.contextValue = 'canResolve';
@@ -61,6 +61,9 @@ export function createVSCodeCommentThreadForReviewThread(
6161
return vscodeThread as GHPRCommentThread;
6262
}
6363

64+
function isResolvedToResolvedState(isResolved: boolean) {
65+
return isResolved ? vscode.CommentThreadState.Resolved : vscode.CommentThreadState.Unresolved;
66+
}
6467

6568
export const COMMENT_EXPAND_STATE_SETTING = 'commentExpandState';
6669
export const COMMENT_EXPAND_STATE_COLLAPSE_VALUE = 'collapseAll';
@@ -84,8 +87,9 @@ export function updateThread(vscodeThread: GHPRCommentThread, reviewThread: IRev
8487
vscodeThread.contextValue = 'canUnresolve';
8588
}
8689

87-
if (vscodeThread.isResolved !== reviewThread.isResolved) {
88-
vscodeThread.isResolved = reviewThread.isResolved;
90+
const newResolvedState = isResolvedToResolvedState(reviewThread.isResolved);
91+
if (vscodeThread.state !== newResolvedState) {
92+
vscodeThread.state = newResolvedState;
8993
}
9094
vscodeThread.collapsibleState = getCommentCollapsibleState(reviewThread.isResolved, expand);
9195

@@ -94,7 +98,7 @@ export function updateThread(vscodeThread: GHPRCommentThread, reviewThread: IRev
9498
}
9599

96100
export function updateCommentThreadLabel(thread: GHPRCommentThread) {
97-
if (thread.isResolved) {
101+
if (thread.state === vscode.CommentThreadState.Resolved) {
98102
thread.label = 'This thread has been marked as resolved';
99103
return;
100104
}

src/test/view/reviewCommentController.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ describe('ReviewCommentController', function () {
140140
comments: [],
141141
collapsibleState: vscode.CommentThreadCollapsibleState.Expanded,
142142
label: 'Start discussion',
143-
isResolved: false,
143+
state: vscode.CommentThreadState.Unresolved,
144144
canReply: false,
145145
dispose: () => {},
146146
};

0 commit comments

Comments
 (0)