Skip to content

Commit 6789129

Browse files
process inside getInitializeContext
1 parent 8304066 commit 6789129

2 files changed

Lines changed: 5 additions & 13 deletions

File tree

src/github/issueOverview.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ export class IssueOverviewPanel<TItem extends IssueModel = IssueModel> extends W
249249
return isInCodespaces();
250250
}
251251

252-
protected getInitializeContext(currentUser: IAccount, issue: IssueModel, timelineEvents: TimelineEvent[], repositoryAccess: RepoAccessAndMergeMethods, viewerCanEdit: boolean, assignableUsers: IAccount[]): Issue {
252+
protected async getInitializeContext(currentUser: IAccount, issue: IssueModel, timelineEvents: TimelineEvent[], repositoryAccess: RepoAccessAndMergeMethods, viewerCanEdit: boolean, assignableUsers: IAccount[]): Promise<Issue> {
253253
const hasWritePermission = repositoryAccess.hasWritePermission;
254254
const canEdit = hasWritePermission || viewerCanEdit;
255255
const labels = issue.item.labels.map(label => ({
@@ -266,12 +266,12 @@ export class IssueOverviewPanel<TItem extends IssueModel = IssueModel> extends W
266266
url: issue.html_url,
267267
createdAt: issue.createdAt,
268268
body: issue.body,
269-
bodyHTML: issue.bodyHTML,
269+
bodyHTML: await this.processLinksInBodyHtml(issue.bodyHTML),
270270
labels: labels,
271271
author: issue.author,
272272
state: issue.state,
273273
stateReason: issue.stateReason,
274-
events: timelineEvents,
274+
events: await this.processTimelineEvents(timelineEvents),
275275
continueOnGitHub: this.continueOnGitHub(),
276276
canEdit,
277277
hasWritePermission,
@@ -322,10 +322,7 @@ export class IssueOverviewPanel<TItem extends IssueModel = IssueModel> extends W
322322
this.setPanelTitle(this.buildPanelTitle(issueModel.number, issueModel.title));
323323

324324
// Process permalinks in bodyHTML before sending to webview
325-
const processedBodyHTML = await this.processLinksInBodyHtml(issue.bodyHTML);
326-
const context = this.getInitializeContext(currentUser, issue, await this.processTimelineEvents(timelineEvents), repositoryAccess, viewerCanEdit, assignableUsers[this._item.remote.remoteName] ?? []);
327-
// Override bodyHTML with processed version without mutating original issue
328-
context.bodyHTML = processedBodyHTML;
325+
const context = await this.getInitializeContext(currentUser, issue, timelineEvents, repositoryAccess, viewerCanEdit, assignableUsers[this._item.remote.remoteName] ?? []);
329326

330327
Logger.debug('pr.initialize', IssueOverviewPanel.ID);
331328
this._postMessage({

src/github/pullRequestOverview.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -403,9 +403,6 @@ export class PullRequestOverviewPanel extends IssueOverviewPanel<PullRequestMode
403403
this._assignableUsers = assignableUsers;
404404
this.setPanelTitle(this.buildPanelTitle(pullRequestModel.number, pullRequestModel.title));
405405

406-
// Process permalinks in bodyHTML before sending to webview
407-
const processedBodyHTML = await this.processLinksInBodyHtml(pullRequest.bodyHTML);
408-
409406
const isCurrentlyCheckedOut = pullRequestModel.equals(this._folderRepositoryManager.activePullRequest);
410407
const mergeMethodsAvailability = repositoryAccess!.mergeMethodsAvailability;
411408

@@ -419,9 +416,7 @@ export class PullRequestOverviewPanel extends IssueOverviewPanel<PullRequestMode
419416
const users = this._assignableUsers[pullRequestModel.remote.remoteName] ?? [];
420417
const copilotUser = users.find(user => COPILOT_ACCOUNTS[user.login]);
421418
const isCopilotAlreadyReviewer = this._existingReviewers.some(reviewer => !isITeam(reviewer.reviewer) && reviewer.reviewer.login === COPILOT_REVIEWER);
422-
const baseContext = this.getInitializeContext(currentUser, pullRequest, await this.processTimelineEvents(timelineEvents), repositoryAccess, viewerCanEdit, users);
423-
// Override bodyHTML with processed version without mutating original pullRequest
424-
baseContext.bodyHTML = processedBodyHTML;
419+
const baseContext = await this.getInitializeContext(currentUser, pullRequest, timelineEvents, repositoryAccess, viewerCanEdit, users);
425420

426421
this.preLoadInfoNotRequiredForOverview(pullRequest);
427422

0 commit comments

Comments
 (0)