Skip to content

Commit

Permalink
Removes redundant try/catch, improves formatting and updates comment
Browse files Browse the repository at this point in the history
  • Loading branch information
axosoft-ramint committed Jan 21, 2025
1 parent 8394748 commit ccd9eb2
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ export abstract class CloudIntegrationAuthenticationProvider<

let session = await cloudIntegrations.getConnectionSession(this.authProviderId);

// Make an exception for GitHub because they always return 0
// Make an exception for GitHub and Cloud Self-Hosted integrations because they always return 0
if (
session?.expiresIn === 0 &&
(this.authProviderId === HostingIntegrationId.GitHub || isCloudSelfHostedIntegrationId(this.authProviderId))
Expand Down
15 changes: 6 additions & 9 deletions src/plus/integrations/integrationService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,10 @@ export class IntegrationService implements Disposable {
private async *getSupportedCloudIntegrations(domainsById: Map<IntegrationId, string>): AsyncIterable<Integration> {
for (const id of getSupportedCloudIntegrationIds()) {
if (isCloudSelfHostedIntegrationId(id) && !domainsById.has(id)) {
try {
// Try getting whatever we have now because we will need to disconnect
const integration = await this.get(id, undefined);
if (integration != null) {
yield integration;
}
} catch {
// Ignore this exception and continue,
// because we probably haven't ever had an instance of this integration
// Try getting whatever we have now because we will need to disconnect
const integration = await this.get(id, undefined);
if (integration != null) {
yield integration;
}
} else {
const integration = await this.get(id, domainsById.get(id));
Expand Down Expand Up @@ -253,6 +248,7 @@ export class IntegrationService implements Disposable {
try {
const integration = await this.get(integrationId);
if (integration == null) continue;

if (integration.maybeConnected ?? (await integration.isConnected())) {
connectedIntegrations.add(integrationId);
}
Expand Down Expand Up @@ -377,6 +373,7 @@ export class IntegrationService implements Disposable {
for (const integrationId of integrationIds) {
const integration = await this.get(integrationId);
if (integration == null) continue;

const connected = integration.maybeConnected ?? (await integration.isConnected());
if (connected && !connectedIntegrations.has(integrationId)) {
return true;
Expand Down
1 change: 1 addition & 0 deletions src/plus/launchpad/launchpad.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ export class LaunchpadCommand extends QuickCommand<State> {
private async ensureIntegrationConnected(id: IntegrationId) {
const integration = await this.container.integrations.get(id);
if (integration == null) return false;

let connected = integration.maybeConnected ?? (await integration.isConnected());
if (!connected) {
connected = await integration.connect('launchpad');
Expand Down
4 changes: 4 additions & 0 deletions src/plus/launchpad/launchpadProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ export class LaunchpadProvider implements Disposable {
.map(async (id: SupportedLaunchpadIntegrationIds) => {
const integration = await this.container.integrations.get(id);
if (integration == null) return;

const searchResult = await searchIntegrationPRs(integration);
const prs = searchResult?.value;
if (prs) {
Expand Down Expand Up @@ -410,6 +411,7 @@ export class LaunchpadProvider implements Disposable {
if (confirm !== 'Merge') return;
const integration = await this.container.integrations.get(integrationId);
if (integration == null) return;

const pr: PullRequest = fromProviderPullRequest(item, integration);
await integration.mergePullRequest(pr);
this.refresh();
Expand Down Expand Up @@ -603,6 +605,7 @@ export class LaunchpadProvider implements Disposable {
if (connectedIntegrations.get(integrationId)) {
const integration = await this.container.integrations.get(integrationId);
if (integration == null) continue;

const prIdentity = integration.getPullRequestIdentityFromMaybeUrl(search);
if (prIdentity) {
return prIdentity;
Expand Down Expand Up @@ -873,6 +876,7 @@ export class LaunchpadProvider implements Disposable {
for (const integrationId of supportedLaunchpadIntegrations) {
const integration = await this.container.integrations.get(integrationId);
if (integration == null) continue;

if (integration.maybeConnected ?? (await integration.isConnected())) {
return true;
}
Expand Down
1 change: 1 addition & 0 deletions src/plus/startWork/startWork.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ export abstract class StartWorkBaseCommand extends QuickCommand<State> {
private async ensureIntegrationConnected(id: IntegrationId) {
const integration = await this.container.integrations.get(id);
if (integration == null) return false;

let connected = integration.maybeConnected ?? (await integration.isConnected());
if (!connected) {
connected = await integration.connect(this.overrides?.ownSource ?? 'startWork');
Expand Down

0 comments on commit ccd9eb2

Please sign in to comment.