Skip to content

Commit ccd9eb2

Browse files
Removes redundant try/catch, improves formatting and updates comment
1 parent 8394748 commit ccd9eb2

File tree

5 files changed

+13
-10
lines changed

5 files changed

+13
-10
lines changed

src/plus/integrations/authentication/integrationAuthentication.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ export abstract class CloudIntegrationAuthenticationProvider<
376376

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

379-
// Make an exception for GitHub because they always return 0
379+
// Make an exception for GitHub and Cloud Self-Hosted integrations because they always return 0
380380
if (
381381
session?.expiresIn === 0 &&
382382
(this.authProviderId === HostingIntegrationId.GitHub || isCloudSelfHostedIntegrationId(this.authProviderId))

src/plus/integrations/integrationService.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -142,15 +142,10 @@ export class IntegrationService implements Disposable {
142142
private async *getSupportedCloudIntegrations(domainsById: Map<IntegrationId, string>): AsyncIterable<Integration> {
143143
for (const id of getSupportedCloudIntegrationIds()) {
144144
if (isCloudSelfHostedIntegrationId(id) && !domainsById.has(id)) {
145-
try {
146-
// Try getting whatever we have now because we will need to disconnect
147-
const integration = await this.get(id, undefined);
148-
if (integration != null) {
149-
yield integration;
150-
}
151-
} catch {
152-
// Ignore this exception and continue,
153-
// because we probably haven't ever had an instance of this integration
145+
// Try getting whatever we have now because we will need to disconnect
146+
const integration = await this.get(id, undefined);
147+
if (integration != null) {
148+
yield integration;
154149
}
155150
} else {
156151
const integration = await this.get(id, domainsById.get(id));
@@ -253,6 +248,7 @@ export class IntegrationService implements Disposable {
253248
try {
254249
const integration = await this.get(integrationId);
255250
if (integration == null) continue;
251+
256252
if (integration.maybeConnected ?? (await integration.isConnected())) {
257253
connectedIntegrations.add(integrationId);
258254
}
@@ -377,6 +373,7 @@ export class IntegrationService implements Disposable {
377373
for (const integrationId of integrationIds) {
378374
const integration = await this.get(integrationId);
379375
if (integration == null) continue;
376+
380377
const connected = integration.maybeConnected ?? (await integration.isConnected());
381378
if (connected && !connectedIntegrations.has(integrationId)) {
382379
return true;

src/plus/launchpad/launchpad.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ export class LaunchpadCommand extends QuickCommand<State> {
200200
private async ensureIntegrationConnected(id: IntegrationId) {
201201
const integration = await this.container.integrations.get(id);
202202
if (integration == null) return false;
203+
203204
let connected = integration.maybeConnected ?? (await integration.isConnected());
204205
if (!connected) {
205206
connected = await integration.connect('launchpad');

src/plus/launchpad/launchpadProvider.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ export class LaunchpadProvider implements Disposable {
275275
.map(async (id: SupportedLaunchpadIntegrationIds) => {
276276
const integration = await this.container.integrations.get(id);
277277
if (integration == null) return;
278+
278279
const searchResult = await searchIntegrationPRs(integration);
279280
const prs = searchResult?.value;
280281
if (prs) {
@@ -410,6 +411,7 @@ export class LaunchpadProvider implements Disposable {
410411
if (confirm !== 'Merge') return;
411412
const integration = await this.container.integrations.get(integrationId);
412413
if (integration == null) return;
414+
413415
const pr: PullRequest = fromProviderPullRequest(item, integration);
414416
await integration.mergePullRequest(pr);
415417
this.refresh();
@@ -603,6 +605,7 @@ export class LaunchpadProvider implements Disposable {
603605
if (connectedIntegrations.get(integrationId)) {
604606
const integration = await this.container.integrations.get(integrationId);
605607
if (integration == null) continue;
608+
606609
const prIdentity = integration.getPullRequestIdentityFromMaybeUrl(search);
607610
if (prIdentity) {
608611
return prIdentity;
@@ -873,6 +876,7 @@ export class LaunchpadProvider implements Disposable {
873876
for (const integrationId of supportedLaunchpadIntegrations) {
874877
const integration = await this.container.integrations.get(integrationId);
875878
if (integration == null) continue;
879+
876880
if (integration.maybeConnected ?? (await integration.isConnected())) {
877881
return true;
878882
}

src/plus/startWork/startWork.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@ export abstract class StartWorkBaseCommand extends QuickCommand<State> {
317317
private async ensureIntegrationConnected(id: IntegrationId) {
318318
const integration = await this.container.integrations.get(id);
319319
if (integration == null) return false;
320+
320321
let connected = integration.maybeConnected ?? (await integration.isConnected());
321322
if (!connected) {
322323
connected = await integration.connect(this.overrides?.ownSource ?? 'startWork');

0 commit comments

Comments
 (0)