diff --git a/deadlock-plugins/deadlock-extension/src/core/controller.ts b/deadlock-plugins/deadlock-extension/src/core/controller.ts index da3c8b386ad3a5b9a8e6fd986cb00eb6d275e29e..7d7d3bb15fec7d1d56978bac11aa52d28b86716f 100644 --- a/deadlock-plugins/deadlock-extension/src/core/controller.ts +++ b/deadlock-plugins/deadlock-extension/src/core/controller.ts @@ -13,7 +13,9 @@ export default class Controller { private briefingView: BriefingView; private quickSetupView: QuickSetupView; private extensionStore: ExtensionStore; + constructor(private context: vscode.ExtensionContext) { + this.extensionStore = ExtensionStore.getInstance(context); this.briefingView = new BriefingView(); this.quickSetupView = new QuickSetupView(context.extensionUri); this.commandHandler = new CommandHandler(this); @@ -22,7 +24,6 @@ export default class Controller { KEYCLOAK_TOKEN_CREATE_URL, KEYCLOAK_USER_INFO_URL, ); - this.extensionStore = ExtensionStore.getInstance(); this.init(); } diff --git a/deadlock-plugins/deadlock-extension/src/core/extensionStore.ts b/deadlock-plugins/deadlock-extension/src/core/extensionStore.ts index cabc1475e8333254ad129ba76f789e422ccc6db9..5d4497c98e99a9929c8e88368d2c8a445bb602cc 100644 --- a/deadlock-plugins/deadlock-extension/src/core/extensionStore.ts +++ b/deadlock-plugins/deadlock-extension/src/core/extensionStore.ts @@ -24,18 +24,12 @@ export default class ExtensionStore { if (await this.secretStorage.get(StoreKey.RefreshTokenKey)) this.secretStorage.delete(StoreKey.RefreshTokenKey); } - public static getInstance(): ExtensionStore { - if (!ExtensionStore.instance) { - throw new Error('ExtensionStore should be initiate with a storage first time'); - } - - return ExtensionStore.instance; - } - - public static createInstance(context: ExtensionContext) { + public static getInstance(context?: ExtensionContext): ExtensionStore { if (!ExtensionStore.instance) { + if (!context) throw new Error('ExtensionStore should be initiate with a storage first time'); ExtensionStore.instance = new ExtensionStore(context); } + return ExtensionStore.instance; } diff --git a/deadlock-plugins/deadlock-extension/src/extension.ts b/deadlock-plugins/deadlock-extension/src/extension.ts index c9f74cbec49ecea20a7c37025c05ccc6b496eebd..1cd5c99a5d095bf35145f582888acc4071b2536e 100644 --- a/deadlock-plugins/deadlock-extension/src/extension.ts +++ b/deadlock-plugins/deadlock-extension/src/extension.ts @@ -11,7 +11,6 @@ export const userConfig = new UserConfigTheia(); export async function activate(context: vscode.ExtensionContext) { vscode.window.showInformationMessage('Bienvenue sur Deadlock!'); - ExtensionStore.createInstance(context); const controller = new Controller(context);