diff --git a/src/commands.ts b/src/commands.ts index ddeb382e3d..0147aa3e1c 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -660,7 +660,8 @@ export function registerCommands( const handler = resolveCommentHandler(reply.thread); if (handler) { - await handler.resolveReviewThread(reply.thread, reply.text); + // Hack. We need to get the original gitHubThreadId back. + await handler.resolveReviewThread(reply.thread.value, reply.text); } }), ); @@ -674,7 +675,8 @@ export function registerCommands( const handler = resolveCommentHandler(reply.thread); if (handler) { - await handler.unresolveReviewThread(reply.thread, reply.text); + // Hack. We need to get the original gitHubThreadId back. + await handler.unresolveReviewThread(reply.thread.value, reply.text); } }), ); diff --git a/src/commentHandlerResolver.ts b/src/commentHandlerResolver.ts index 3b7e958237..8fa56f0caa 100644 --- a/src/commentHandlerResolver.ts +++ b/src/commentHandlerResolver.ts @@ -24,7 +24,7 @@ export interface CommentHandler { } export interface CommentReply { - thread: GHPRCommentThread; + thread: GHPRCommentThread & { value: GHPRCommentThread }; text: string; } @@ -45,7 +45,7 @@ export function resolveCommentHandler(commentThread: GHPRCommentThread): Comment } } - Logger.appendLine(`Unable to find handler for comment thread ${commentThread.threadId}`); + Logger.appendLine(`Unable to find handler for comment thread ${commentThread.gitHubThreadId}`); return; } diff --git a/src/github/prComment.ts b/src/github/prComment.ts index 2fdce1ce7a..d98d0ad0f9 100644 --- a/src/github/prComment.ts +++ b/src/github/prComment.ts @@ -9,7 +9,7 @@ import { IAccount } from './interface'; import { updateCommentReactions } from './utils'; export interface GHPRCommentThread extends vscode.CommentThread { - threadId: string; + gitHubThreadId: string; /** * The uri of the document the thread has been created on. diff --git a/src/github/utils.ts b/src/github/utils.ts index fe98ae0824..5a49cee02c 100644 --- a/src/github/utils.ts +++ b/src/github/utils.ts @@ -43,7 +43,7 @@ export function createVSCodeCommentThreadForReviewThread( ): GHPRCommentThread { const vscodeThread = commentController.createCommentThread(uri, range, []); - (vscodeThread as GHPRCommentThread).threadId = thread.id; + (vscodeThread as GHPRCommentThread).gitHubThreadId = thread.id; vscodeThread.comments = thread.comments.map(comment => new GHPRComment(comment, vscodeThread as GHPRCommentThread)); (vscodeThread as GHPRCommentThread).isResolved = thread.isResolved; diff --git a/src/test/view/reviewCommentController.test.ts b/src/test/view/reviewCommentController.test.ts index 4f0b20cc58..018a61525f 100644 --- a/src/test/view/reviewCommentController.test.ts +++ b/src/test/view/reviewCommentController.test.ts @@ -128,7 +128,7 @@ describe('ReviewCommentController', function () { function createGHPRCommentThread(threadId: string, uri: vscode.Uri): GHPRCommentThread { return { - threadId, + gitHubThreadId: threadId, uri, range: new vscode.Range(new vscode.Position(21, 0), new vscode.Position(21, 0)), comments: [], diff --git a/src/view/pullRequestCommentController.ts b/src/view/pullRequestCommentController.ts index 5ad4d0dc20..2747d1513e 100644 --- a/src/view/pullRequestCommentController.ts +++ b/src/view/pullRequestCommentController.ts @@ -171,7 +171,7 @@ export class PullRequestCommentController implements CommentHandler, CommentReac let newThread: GHPRCommentThread | undefined = undefined; if (index > -1) { newThread = this._pendingCommentThreadAdds[index]; - newThread.threadId = thread.id; + newThread.gitHubThreadId = thread.id; newThread.comments = thread.comments.map(c => new GHPRComment(c, newThread!)); this._pendingCommentThreadAdds.splice(index, 1); } else { @@ -212,7 +212,7 @@ export class PullRequestCommentController implements CommentHandler, CommentReac e.changed.forEach(thread => { const key = this.getCommentThreadCacheKey(thread.path, thread.diffSide === DiffSide.LEFT); - const index = this._commentThreadCache[key].findIndex(t => t.threadId === thread.id); + const index = this._commentThreadCache[key].findIndex(t => t.gitHubThreadId === thread.id); if (index > -1) { const matchingThread = this._commentThreadCache[key][index]; updateThread(matchingThread, thread); @@ -221,7 +221,7 @@ export class PullRequestCommentController implements CommentHandler, CommentReac e.removed.forEach(async thread => { const key = this.getCommentThreadCacheKey(thread.path, thread.diffSide === DiffSide.LEFT); - const index = this._commentThreadCache[key].findIndex(t => t.threadId === thread.id); + const index = this._commentThreadCache[key].findIndex(t => t.gitHubThreadId === thread.id); if (index > -1) { const matchingThread = this._commentThreadCache[key][index]; this._commentThreadCache[key].splice(index, 1); @@ -432,7 +432,7 @@ export class PullRequestCommentController implements CommentHandler, CommentReac await this.createCommentOnResolve(thread, input); } - await this.pullRequestModel.resolveReviewThread(thread.threadId); + await this.pullRequestModel.resolveReviewThread(thread.gitHubThreadId); } catch (e) { vscode.window.showErrorMessage(`Resolving conversation failed: ${e}`); } @@ -444,7 +444,7 @@ export class PullRequestCommentController implements CommentHandler, CommentReac await this.createCommentOnResolve(thread, input); } - await this.pullRequestModel.unresolveReviewThread(thread.threadId); + await this.pullRequestModel.unresolveReviewThread(thread.gitHubThreadId); } catch (e) { vscode.window.showErrorMessage(`Unresolving conversation failed: ${e}`); } diff --git a/src/view/reviewCommentController.ts b/src/view/reviewCommentController.ts index ce778e6437..7bc2a76eb2 100644 --- a/src/view/reviewCommentController.ts +++ b/src/view/reviewCommentController.ts @@ -236,7 +236,7 @@ export class ReviewCommentController let newThread: GHPRCommentThread; if (index > -1) { newThread = this._pendingCommentThreadAdds[index]; - newThread.threadId = thread.id; + newThread.gitHubThreadId = thread.id; newThread.comments = thread.comments.map(c => new GHPRComment(c, newThread)); this._pendingCommentThreadAdds.splice(index, 1); } else { @@ -273,7 +273,7 @@ export class ReviewCommentController ? this._workspaceFileChangeCommentThreads : this._reviewSchemeFileChangeCommentThreads; - const index = threadMap[thread.path].findIndex(t => t.threadId === thread.id); + const index = threadMap[thread.path].findIndex(t => t.gitHubThreadId === thread.id); if (index > -1) { const matchingThread = threadMap[thread.path][index]; updateThread(matchingThread, thread); @@ -287,7 +287,7 @@ export class ReviewCommentController ? this._workspaceFileChangeCommentThreads : this._reviewSchemeFileChangeCommentThreads; - const index = threadMap[thread.path].findIndex(t => t.threadId === thread.id); + const index = threadMap[thread.path].findIndex(t => t.gitHubThreadId === thread.id); if (index > -1) { const matchingThread = threadMap[thread.path][index]; threadMap[thread.path].splice(index, 1); @@ -651,7 +651,7 @@ export class ReviewCommentController await this.createCommentOnResolve(thread, input); } - await this._reposManager.activePullRequest!.resolveReviewThread(thread.threadId); + await this._reposManager.activePullRequest!.resolveReviewThread(thread.gitHubThreadId); } catch (e) { vscode.window.showErrorMessage(`Resolving conversation failed: ${e}`); } @@ -663,7 +663,7 @@ export class ReviewCommentController await this.createCommentOnResolve(thread, input); } - await this._reposManager.activePullRequest!.unresolveReviewThread(thread.threadId); + await this._reposManager.activePullRequest!.unresolveReviewThread(thread.gitHubThreadId); } catch (e) { vscode.window.showErrorMessage(`Unresolving conversation failed: ${e}`); }