From 0b52b3a177593677cd2da3bceb6a20d8b88ef85b Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Thu, 9 Jun 2022 00:34:25 -0400 Subject: [PATCH] Avoids Container.config for single setting lookup --- src/git/remotes/provider.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/git/remotes/provider.ts b/src/git/remotes/provider.ts index 814d62d..dfb7fbe 100644 --- a/src/git/remotes/provider.ts +++ b/src/git/remotes/provider.ts @@ -10,6 +10,7 @@ import { } from 'vscode'; import { DynamicAutolinkReference } from '../../annotations/autolinks'; import { AutolinkReference } from '../../config'; +import { configuration } from '../../configuration'; import { Container } from '../../container'; import { AuthenticationError, ProviderRequestClientError } from '../../errors'; import { Logger } from '../../logger'; @@ -574,12 +575,13 @@ export abstract class RichRemoteProvider extends RemoteProvider { @gate() private async ensureSession(createIfNeeded: boolean): Promise { if (this._session != null) return this._session; + if (!configuration.get('integrations.enabled')) return undefined; - if (!Container.instance.config.integrations.enabled) return undefined; + const { instance: container } = Container; if (createIfNeeded) { - await Container.instance.storage.deleteWorkspace(this.connectedKey); - } else if (Container.instance.storage.getWorkspace(this.connectedKey) === false) { + await container.storage.deleteWorkspace(this.connectedKey); + } else if (container.storage.getWorkspace(this.connectedKey) === false) { return undefined; } @@ -590,7 +592,7 @@ export abstract class RichRemoteProvider extends RemoteProvider { silent: !createIfNeeded, }); } catch (ex) { - await Container.instance.storage.deleteWorkspace(this.connectedKey); + await container.storage.deleteWorkspace(this.connectedKey); if (ex instanceof Error && ex.message.includes('User did not consent')) { return undefined; @@ -600,14 +602,14 @@ export abstract class RichRemoteProvider extends RemoteProvider { } if (session === undefined && !createIfNeeded) { - await Container.instance.storage.deleteWorkspace(this.connectedKey); + await container.storage.deleteWorkspace(this.connectedKey); } this._session = session ?? null; this.invalidClientExceptionCount = 0; if (session != null) { - await Container.instance.storage.storeWorkspace(this.connectedKey, true); + await container.storage.storeWorkspace(this.connectedKey, true); queueMicrotask(() => { this._onDidChange.fire();