Skip to content

Commit

Permalink
Reuses connected integrations by passing to getPullRequestIdentity...
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeibbb committed Dec 23, 2024
1 parent e23ff4a commit 6b5a763
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/plus/launchpad/launchpadProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,14 +214,16 @@ export class LaunchpadProvider implements Disposable {
}

private async getSearchedPullRequests(search: string, cancellation?: CancellationToken) {
const prUrlIdentity: PullRequestUrlIdentity | undefined = await this.getPullRequestIdentityFromMaybeUrl(search);
const connectedIntegrations = await this.getConnectedIntegrations();
const prUrlIdentity: PullRequestUrlIdentity | undefined = await this.getPullRequestIdentityFromMaybeUrl(
search,
connectedIntegrations,
);
const result: { readonly value: SearchedPullRequest[]; duration: number } = {
value: [],
duration: 0,
};

const connectedIntegrations = await this.getConnectedIntegrations();

const findByPrIdentity = async (
integration: HostingIntegration,
): Promise<undefined | TimedResult<SearchedPullRequest[] | undefined>> => {
Expand Down Expand Up @@ -596,8 +598,10 @@ export class LaunchpadProvider implements Disposable {
// - cons: it's async
// What do you think?

async getPullRequestIdentityFromMaybeUrl(search: string): Promise<PullRequestUrlIdentity | undefined> {
const connectedIntegrations = await this.getConnectedIntegrations();
async getPullRequestIdentityFromMaybeUrl(
search: string,
connectedIntegrations: Map<IntegrationId, boolean>,
): Promise<PullRequestUrlIdentity | undefined> {
for (const integrationId of supportedLaunchpadIntegrations) {
if (connectedIntegrations.get(integrationId)) {
const integration = await this.container.integrations.get(integrationId);
Expand Down

0 comments on commit 6b5a763

Please sign in to comment.