Browse Source

Avoids Container.config for single setting lookup

main
Eric Amodio 2 years ago
parent
commit
0b52b3a177
1 changed files with 8 additions and 6 deletions
  1. +8
    -6
      src/git/remotes/provider.ts

+ 8
- 6
src/git/remotes/provider.ts View File

@ -10,6 +10,7 @@ import {
} from 'vscode'; } from 'vscode';
import { DynamicAutolinkReference } from '../../annotations/autolinks'; import { DynamicAutolinkReference } from '../../annotations/autolinks';
import { AutolinkReference } from '../../config'; import { AutolinkReference } from '../../config';
import { configuration } from '../../configuration';
import { Container } from '../../container'; import { Container } from '../../container';
import { AuthenticationError, ProviderRequestClientError } from '../../errors'; import { AuthenticationError, ProviderRequestClientError } from '../../errors';
import { Logger } from '../../logger'; import { Logger } from '../../logger';
@ -574,12 +575,13 @@ export abstract class RichRemoteProvider extends RemoteProvider {
@gate() @gate()
private async ensureSession(createIfNeeded: boolean): Promise<AuthenticationSession | undefined> { private async ensureSession(createIfNeeded: boolean): Promise<AuthenticationSession | undefined> {
if (this._session != null) return this._session; 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) { if (createIfNeeded) {
await Container.instance.storage.deleteWorkspace(this.connectedKey);
} else if (Container.instance.storage.getWorkspace<boolean>(this.connectedKey) === false) {
await container.storage.deleteWorkspace(this.connectedKey);
} else if (container.storage.getWorkspace<boolean>(this.connectedKey) === false) {
return undefined; return undefined;
} }
@ -590,7 +592,7 @@ export abstract class RichRemoteProvider extends RemoteProvider {
silent: !createIfNeeded, silent: !createIfNeeded,
}); });
} catch (ex) { } 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')) { if (ex instanceof Error && ex.message.includes('User did not consent')) {
return undefined; return undefined;
@ -600,14 +602,14 @@ export abstract class RichRemoteProvider extends RemoteProvider {
} }
if (session === undefined && !createIfNeeded) { if (session === undefined && !createIfNeeded) {
await Container.instance.storage.deleteWorkspace(this.connectedKey);
await container.storage.deleteWorkspace(this.connectedKey);
} }
this._session = session ?? null; this._session = session ?? null;
this.invalidClientExceptionCount = 0; this.invalidClientExceptionCount = 0;
if (session != null) { if (session != null) {
await Container.instance.storage.storeWorkspace(this.connectedKey, true);
await container.storage.storeWorkspace(this.connectedKey, true);
queueMicrotask(() => { queueMicrotask(() => {
this._onDidChange.fire(); this._onDidChange.fire();

Loading…
Cancel
Save