Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}),
);
Expand All @@ -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);
}
}),
);
Expand Down
4 changes: 2 additions & 2 deletions src/commentHandlerResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export interface CommentHandler {
}

export interface CommentReply {
thread: GHPRCommentThread;
thread: GHPRCommentThread & { value: GHPRCommentThread };
text: string;
}

Expand All @@ -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;
}
2 changes: 1 addition & 1 deletion src/github/prComment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/github/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/test/view/reviewCommentController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [],
Expand Down
10 changes: 5 additions & 5 deletions src/view/pullRequestCommentController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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}`);
}
Expand All @@ -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}`);
}
Expand Down
10 changes: 5 additions & 5 deletions src/view/reviewCommentController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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}`);
}
Expand All @@ -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}`);
}
Expand Down