Skip to content

Commit e369d09

Browse files
Copilotalexr00
andcommitted
Refactor: Extract helper method to reduce code duplication in pullRequestNode
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
1 parent a86075d commit e369d09

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

src/view/treeNodes/pullRequestNode.ts

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -270,16 +270,20 @@ export class PRNode extends TreeNode implements vscode.CommentingRangeProvider2
270270
});
271271
}
272272

273+
private async _getAuthorIcon(): Promise<vscode.Uri | vscode.ThemeIcon> {
274+
// For enterprise, use placeholder icon instead of trying to fetch avatar
275+
if (this.pullRequestModel.githubRepository.remote.isEnterprise) {
276+
return new vscode.ThemeIcon('github');
277+
}
278+
return (await DataUri.avatarCirclesAsImageDataUris(this._folderReposManager.context, [this.pullRequestModel.author], 16, 16))[0]
279+
?? new vscode.ThemeIcon('github');
280+
}
281+
273282
private async _getIcon(): Promise<vscode.Uri | vscode.ThemeIcon | { light: vscode.Uri; dark: vscode.Uri }> {
274283
const copilotWorkingStatus = await this.pullRequestModel.copilotWorkingStatus();
275284
const theme = this._folderReposManager.themeWatcher.themeData;
276285
if (copilotWorkingStatus === CopilotWorkingStatus.NotCopilotIssue) {
277-
// For enterprise, use placeholder icon instead of trying to fetch avatar
278-
if (this.pullRequestModel.githubRepository.remote.isEnterprise) {
279-
return new vscode.ThemeIcon('github');
280-
}
281-
return (await DataUri.avatarCirclesAsImageDataUris(this._folderReposManager.context, [this.pullRequestModel.author], 16, 16))[0]
282-
?? new vscode.ThemeIcon('github');
286+
return this._getAuthorIcon();
283287
}
284288
switch (copilotWorkingStatus) {
285289
case CopilotWorkingStatus.InProgress:
@@ -298,12 +302,7 @@ export class PRNode extends TreeNode implements vscode.CommentingRangeProvider2
298302
dark: DataUri.copilotErrorAsImageDataURI(getIconForeground(theme, 'dark'), getListErrorForeground(theme, 'dark'))
299303
};
300304
default:
301-
// For enterprise, use placeholder icon instead of trying to fetch avatar
302-
if (this.pullRequestModel.githubRepository.remote.isEnterprise) {
303-
return new vscode.ThemeIcon('github');
304-
}
305-
return (await DataUri.avatarCirclesAsImageDataUris(this._folderReposManager.context, [this.pullRequestModel.author], 16, 16))[0]
306-
?? new vscode.ThemeIcon('github');
305+
return this._getAuthorIcon();
307306
}
308307
}
309308

0 commit comments

Comments
 (0)