Skip to content

Commit 7a6e85f

Browse files
authored
Command 'GitHub Pull Requests: Unresolve Conversation' resulted in an error (#6626)
* Command 'GitHub Pull Requests: Unresolve Conversation' resulted in an error Fixes #6620 * Fix compile error
1 parent 698261c commit 7a6e85f

File tree

2 files changed

+40
-18
lines changed

2 files changed

+40
-18
lines changed

package.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1932,6 +1932,18 @@
19321932
"command": "pr.deleteComment",
19331933
"when": "false"
19341934
},
1935+
{
1936+
"command": "pr.unresolveReviewThread",
1937+
"when": "false"
1938+
},
1939+
{
1940+
"command": "pr.unresolveReviewThreadFromView",
1941+
"when": "false"
1942+
},
1943+
{
1944+
"command": "pr.resolveReviewThread",
1945+
"when": "false"
1946+
},
19351947
{
19361948
"command": "pr.openReview",
19371949
"when": "false"

src/commands.ts

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -981,44 +981,54 @@ export function registerCommands(
981981
return { thread, text };
982982
}
983983

984-
context.subscriptions.push(
985-
vscode.commands.registerCommand('pr.resolveReviewThread', async (commentLike: CommentReply | GHPRCommentThread | GHPRComment) => {
984+
const resolve = async (commentLike: CommentReply | GHPRCommentThread | GHPRComment | undefined, resolve: boolean, focusReply?: boolean) => {
985+
if (resolve) {
986986
/* __GDPR__
987987
"pr.resolveReviewThread" : {}
988988
*/
989989
telemetry.sendTelemetryEvent('pr.resolveReviewThread');
990-
const { thread, text } = threadAndText(commentLike);
991-
const handler = resolveCommentHandler(thread);
990+
} else {
991+
/* __GDPR__
992+
"pr.unresolveReviewThread" : {}
993+
*/
994+
telemetry.sendTelemetryEvent('pr.unresolveReviewThread');
995+
}
992996

993-
if (handler) {
994-
await handler.resolveReviewThread(thread, text);
997+
if (!commentLike) {
998+
const activeHandler = findActiveHandler();
999+
if (!activeHandler) {
1000+
vscode.window.showErrorMessage(vscode.l10n.t('No active comment thread found'));
1001+
return;
9951002
}
996-
}),
997-
);
1003+
commentLike = activeHandler.commentController.activeCommentThread as vscode.CommentThread2 as GHPRCommentThread;
1004+
}
9981005

999-
const unresolve = async (commentLike: CommentReply | GHPRCommentThread | GHPRComment, focusReply: boolean) => {
1000-
/* __GDPR__
1001-
"pr.unresolveReviewThread" : {}
1002-
*/
1003-
telemetry.sendTelemetryEvent('pr.unresolveReviewThread');
10041006
const { thread, text } = threadAndText(commentLike);
10051007

10061008
const handler = resolveCommentHandler(thread);
10071009

10081010
if (handler) {
1009-
await handler.unresolveReviewThread(thread, text);
1010-
if (focusReply) {
1011-
thread.reveal(undefined, { focus: vscode.CommentThreadFocus.Reply });
1011+
if (resolve) {
1012+
await handler.resolveReviewThread(thread, text);
1013+
} else {
1014+
await handler.unresolveReviewThread(thread, text);
1015+
if (focusReply) {
1016+
thread.reveal(undefined, { focus: vscode.CommentThreadFocus.Reply });
1017+
}
10121018
}
10131019
}
10141020
};
10151021

10161022
context.subscriptions.push(
1017-
vscode.commands.registerCommand('pr.unresolveReviewThread', (commentLike: CommentReply | GHPRCommentThread | GHPRComment) => unresolve(commentLike, false))
1023+
vscode.commands.registerCommand('pr.resolveReviewThread', async (commentLike: CommentReply | GHPRCommentThread | GHPRComment) => resolve(commentLike, true))
1024+
);
1025+
1026+
context.subscriptions.push(
1027+
vscode.commands.registerCommand('pr.unresolveReviewThread', (commentLike: CommentReply | GHPRCommentThread | GHPRComment) => resolve(commentLike, false, false))
10181028
);
10191029

10201030
context.subscriptions.push(
1021-
vscode.commands.registerCommand('pr.unresolveReviewThreadFromView', (commentLike: CommentReply | GHPRCommentThread | GHPRComment) => unresolve(commentLike, true))
1031+
vscode.commands.registerCommand('pr.unresolveReviewThreadFromView', (commentLike: CommentReply | GHPRCommentThread | GHPRComment) => resolve(commentLike, false, true))
10221032
);
10231033

10241034
const localUriFromReviewUri = (reviewUri: vscode.Uri) => {

0 commit comments

Comments
 (0)