Skip to content

Commit 70d39c2

Browse files
authored
Could not resolve conversation on old PR (#2883)
Fixes #2857
1 parent adb7411 commit 70d39c2

File tree

7 files changed

+19
-17
lines changed

7 files changed

+19
-17
lines changed

src/commands.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,8 @@ export function registerCommands(
660660
const handler = resolveCommentHandler(reply.thread);
661661

662662
if (handler) {
663-
await handler.resolveReviewThread(reply.thread, reply.text);
663+
// Hack. We need to get the original gitHubThreadId back.
664+
await handler.resolveReviewThread(reply.thread.value, reply.text);
664665
}
665666
}),
666667
);
@@ -674,7 +675,8 @@ export function registerCommands(
674675
const handler = resolveCommentHandler(reply.thread);
675676

676677
if (handler) {
677-
await handler.unresolveReviewThread(reply.thread, reply.text);
678+
// Hack. We need to get the original gitHubThreadId back.
679+
await handler.unresolveReviewThread(reply.thread.value, reply.text);
678680
}
679681
}),
680682
);

src/commentHandlerResolver.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export interface CommentHandler {
2424
}
2525

2626
export interface CommentReply {
27-
thread: GHPRCommentThread;
27+
thread: GHPRCommentThread & { value: GHPRCommentThread };
2828
text: string;
2929
}
3030

@@ -45,7 +45,7 @@ export function resolveCommentHandler(commentThread: GHPRCommentThread): Comment
4545
}
4646
}
4747

48-
Logger.appendLine(`Unable to find handler for comment thread ${commentThread.threadId}`);
48+
Logger.appendLine(`Unable to find handler for comment thread ${commentThread.gitHubThreadId}`);
4949

5050
return;
5151
}

src/github/prComment.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { IAccount } from './interface';
99
import { updateCommentReactions } from './utils';
1010

1111
export interface GHPRCommentThread extends vscode.CommentThread {
12-
threadId: string;
12+
gitHubThreadId: string;
1313

1414
/**
1515
* The uri of the document the thread has been created on.

src/github/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export function createVSCodeCommentThreadForReviewThread(
4343
): GHPRCommentThread {
4444
const vscodeThread = commentController.createCommentThread(uri, range, []);
4545

46-
(vscodeThread as GHPRCommentThread).threadId = thread.id;
46+
(vscodeThread as GHPRCommentThread).gitHubThreadId = thread.id;
4747

4848
vscodeThread.comments = thread.comments.map(comment => new GHPRComment(comment, vscodeThread as GHPRCommentThread));
4949
(vscodeThread as GHPRCommentThread).isResolved = thread.isResolved;

src/test/view/reviewCommentController.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ describe('ReviewCommentController', function () {
128128

129129
function createGHPRCommentThread(threadId: string, uri: vscode.Uri): GHPRCommentThread {
130130
return {
131-
threadId,
131+
gitHubThreadId: threadId,
132132
uri,
133133
range: new vscode.Range(new vscode.Position(21, 0), new vscode.Position(21, 0)),
134134
comments: [],

src/view/pullRequestCommentController.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ export class PullRequestCommentController implements CommentHandler, CommentReac
171171
let newThread: GHPRCommentThread | undefined = undefined;
172172
if (index > -1) {
173173
newThread = this._pendingCommentThreadAdds[index];
174-
newThread.threadId = thread.id;
174+
newThread.gitHubThreadId = thread.id;
175175
newThread.comments = thread.comments.map(c => new GHPRComment(c, newThread!));
176176
this._pendingCommentThreadAdds.splice(index, 1);
177177
} else {
@@ -212,7 +212,7 @@ export class PullRequestCommentController implements CommentHandler, CommentReac
212212

213213
e.changed.forEach(thread => {
214214
const key = this.getCommentThreadCacheKey(thread.path, thread.diffSide === DiffSide.LEFT);
215-
const index = this._commentThreadCache[key].findIndex(t => t.threadId === thread.id);
215+
const index = this._commentThreadCache[key].findIndex(t => t.gitHubThreadId === thread.id);
216216
if (index > -1) {
217217
const matchingThread = this._commentThreadCache[key][index];
218218
updateThread(matchingThread, thread);
@@ -221,7 +221,7 @@ export class PullRequestCommentController implements CommentHandler, CommentReac
221221

222222
e.removed.forEach(async thread => {
223223
const key = this.getCommentThreadCacheKey(thread.path, thread.diffSide === DiffSide.LEFT);
224-
const index = this._commentThreadCache[key].findIndex(t => t.threadId === thread.id);
224+
const index = this._commentThreadCache[key].findIndex(t => t.gitHubThreadId === thread.id);
225225
if (index > -1) {
226226
const matchingThread = this._commentThreadCache[key][index];
227227
this._commentThreadCache[key].splice(index, 1);
@@ -432,7 +432,7 @@ export class PullRequestCommentController implements CommentHandler, CommentReac
432432
await this.createCommentOnResolve(thread, input);
433433
}
434434

435-
await this.pullRequestModel.resolveReviewThread(thread.threadId);
435+
await this.pullRequestModel.resolveReviewThread(thread.gitHubThreadId);
436436
} catch (e) {
437437
vscode.window.showErrorMessage(`Resolving conversation failed: ${e}`);
438438
}
@@ -444,7 +444,7 @@ export class PullRequestCommentController implements CommentHandler, CommentReac
444444
await this.createCommentOnResolve(thread, input);
445445
}
446446

447-
await this.pullRequestModel.unresolveReviewThread(thread.threadId);
447+
await this.pullRequestModel.unresolveReviewThread(thread.gitHubThreadId);
448448
} catch (e) {
449449
vscode.window.showErrorMessage(`Unresolving conversation failed: ${e}`);
450450
}

src/view/reviewCommentController.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ export class ReviewCommentController
236236
let newThread: GHPRCommentThread;
237237
if (index > -1) {
238238
newThread = this._pendingCommentThreadAdds[index];
239-
newThread.threadId = thread.id;
239+
newThread.gitHubThreadId = thread.id;
240240
newThread.comments = thread.comments.map(c => new GHPRComment(c, newThread));
241241
this._pendingCommentThreadAdds.splice(index, 1);
242242
} else {
@@ -273,7 +273,7 @@ export class ReviewCommentController
273273
? this._workspaceFileChangeCommentThreads
274274
: this._reviewSchemeFileChangeCommentThreads;
275275

276-
const index = threadMap[thread.path].findIndex(t => t.threadId === thread.id);
276+
const index = threadMap[thread.path].findIndex(t => t.gitHubThreadId === thread.id);
277277
if (index > -1) {
278278
const matchingThread = threadMap[thread.path][index];
279279
updateThread(matchingThread, thread);
@@ -287,7 +287,7 @@ export class ReviewCommentController
287287
? this._workspaceFileChangeCommentThreads
288288
: this._reviewSchemeFileChangeCommentThreads;
289289

290-
const index = threadMap[thread.path].findIndex(t => t.threadId === thread.id);
290+
const index = threadMap[thread.path].findIndex(t => t.gitHubThreadId === thread.id);
291291
if (index > -1) {
292292
const matchingThread = threadMap[thread.path][index];
293293
threadMap[thread.path].splice(index, 1);
@@ -651,7 +651,7 @@ export class ReviewCommentController
651651
await this.createCommentOnResolve(thread, input);
652652
}
653653

654-
await this._reposManager.activePullRequest!.resolveReviewThread(thread.threadId);
654+
await this._reposManager.activePullRequest!.resolveReviewThread(thread.gitHubThreadId);
655655
} catch (e) {
656656
vscode.window.showErrorMessage(`Resolving conversation failed: ${e}`);
657657
}
@@ -663,7 +663,7 @@ export class ReviewCommentController
663663
await this.createCommentOnResolve(thread, input);
664664
}
665665

666-
await this._reposManager.activePullRequest!.unresolveReviewThread(thread.threadId);
666+
await this._reposManager.activePullRequest!.unresolveReviewThread(thread.gitHubThreadId);
667667
} catch (e) {
668668
vscode.window.showErrorMessage(`Unresolving conversation failed: ${e}`);
669669
}

0 commit comments

Comments
 (0)