Skip to content

Commit 286849c

Browse files
Copilotalexr00
andcommitted
Pass currentUser to updateThread for newly created comments
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
1 parent 89802fd commit 286849c

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

src/github/utils.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ export function getCommentCollapsibleState(thread: IReviewThread, expand?: boole
175175
}
176176

177177

178-
export function updateThreadWithRange(context: vscode.ExtensionContext, vscodeThread: GHPRCommentThread, reviewThread: IReviewThread, githubRepositories?: GitHubRepository[], expand?: boolean) {
178+
export function updateThreadWithRange(context: vscode.ExtensionContext, vscodeThread: GHPRCommentThread, reviewThread: IReviewThread, githubRepositories?: GitHubRepository[], expand?: boolean, currentUser?: string) {
179179
if (!vscodeThread.range) {
180180
return;
181181
}
@@ -184,13 +184,13 @@ export function updateThreadWithRange(context: vscode.ExtensionContext, vscodeTh
184184
if (editor.document.uri.toString() === vscodeThread.uri.toString()) {
185185
const endLine = editor.document.lineAt(vscodeThread.range.end.line);
186186
const range = new vscode.Range(vscodeThread.range.start.line, 0, vscodeThread.range.end.line, endLine.text.length);
187-
updateThread(context, vscodeThread, reviewThread, githubRepositories, expand, range);
187+
updateThread(context, vscodeThread, reviewThread, githubRepositories, expand, range, currentUser);
188188
break;
189189
}
190190
}
191191
}
192192

193-
export function updateThread(context: vscode.ExtensionContext, vscodeThread: GHPRCommentThread, reviewThread: IReviewThread, githubRepositories?: GitHubRepository[], expand?: boolean, range?: vscode.Range) {
193+
export function updateThread(context: vscode.ExtensionContext, vscodeThread: GHPRCommentThread, reviewThread: IReviewThread, githubRepositories?: GitHubRepository[], expand?: boolean, range?: vscode.Range, currentUser?: string) {
194194
if (reviewThread.viewerCanResolve && !reviewThread.isResolved) {
195195
vscodeThread.contextValue = 'canResolve';
196196
} else if (reviewThread.viewerCanUnresolve && reviewThread.isResolved) {
@@ -209,7 +209,7 @@ export function updateThread(context: vscode.ExtensionContext, vscodeThread: GHP
209209
applicability: newApplicabilityState
210210
};
211211
}
212-
vscodeThread.collapsibleState = getCommentCollapsibleState(reviewThread, expand);
212+
vscodeThread.collapsibleState = getCommentCollapsibleState(reviewThread, expand, currentUser);
213213
if (range) {
214214
vscodeThread.range = range;
215215
}

src/view/pullRequestCommentController.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,8 @@ export class PullRequestCommentController extends CommentControllerBase implemen
241241
newThread = this._pendingCommentThreadAdds[index];
242242
newThread.gitHubThreadId = thread.id;
243243
newThread.comments = thread.comments.map(c => new GHPRComment(this._context, c, newThread!, this._githubRepositories));
244-
updateThreadWithRange(this._context, newThread, thread, this._githubRepositories);
244+
const currentUser = await this._folderRepoManager.getCurrentUser();
245+
updateThreadWithRange(this._context, newThread, thread, this._githubRepositories, undefined, currentUser.login);
245246
this._pendingCommentThreadAdds.splice(index, 1);
246247
} else {
247248
const openPREditors = await this.getPREditors(vscode.window.visibleTextEditors);

src/view/reviewCommentController.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,8 @@ export class ReviewCommentController extends CommentControllerBase implements Co
297297
newThread = this._pendingCommentThreadAdds[index];
298298
newThread.gitHubThreadId = thread.id;
299299
newThread.comments = thread.comments.map(c => new GHPRComment(this._context, c, newThread, githubRepositories));
300-
updateThreadWithRange(this._context, newThread, thread, githubRepositories);
300+
const currentUser = await this._folderRepoManager.getCurrentUser(this._folderRepoManager.activePullRequest!.githubRepository);
301+
updateThreadWithRange(this._context, newThread, thread, githubRepositories, undefined, currentUser.login);
301302
this._pendingCommentThreadAdds.splice(index, 1);
302303
} else {
303304
const fullPath = nodePath.join(this._repository.rootUri.path, path).replace(/\\/g, '/');

0 commit comments

Comments
 (0)