diff --git a/arduino-ide-extension/src/browser/auth/authentication-client-service.ts b/arduino-ide-extension/src/browser/auth/authentication-client-service.ts index 2b0fb9cdf..3990ecd56 100644 --- a/arduino-ide-extension/src/browser/auth/authentication-client-service.ts +++ b/arduino-ide-extension/src/browser/auth/authentication-client-service.ts @@ -49,7 +49,10 @@ export class AuthenticationClientService this.service .session() .then((session) => this.notifySessionDidChange(session)); + this.setOptions(); + this.service.initAuthSession() + this.arduinoPreferences.onPreferenceChanged((event) => { if (event.preferenceName.startsWith('arduino.auth.')) { this.setOptions(); diff --git a/arduino-ide-extension/src/common/protocol/authentication-service.ts b/arduino-ide-extension/src/common/protocol/authentication-service.ts index 227427793..df9662ffe 100644 --- a/arduino-ide-extension/src/common/protocol/authentication-service.ts +++ b/arduino-ide-extension/src/common/protocol/authentication-service.ts @@ -23,6 +23,7 @@ export interface AuthenticationService session(): Promise; disposeClient(client: AuthenticationServiceClient): void; setOptions(authOptions: AuthOptions): void; + initAuthSession(): Promise; } export interface AuthenticationServiceClient { diff --git a/arduino-ide-extension/src/node/auth/authentication-service-impl.ts b/arduino-ide-extension/src/node/auth/authentication-service-impl.ts index c0ec42c8c..73906cee4 100644 --- a/arduino-ide-extension/src/node/auth/authentication-service-impl.ts +++ b/arduino-ide-extension/src/node/auth/authentication-service-impl.ts @@ -19,6 +19,8 @@ export class AuthenticationServiceImpl protected readonly delegate = new ArduinoAuthenticationProvider(); protected readonly clients: AuthenticationServiceClient[] = []; protected readonly toDispose = new DisposableCollection(); + + private initialized = false; async onStart(): Promise { this.toDispose.pushAll([ @@ -42,7 +44,13 @@ export class AuthenticationServiceImpl this.clients.forEach((client) => this.disposeClient(client)) ), ]); - await this.delegate.init(); + } + + async initAuthSession(): Promise { + if (!this.initialized) { + await this.delegate.init(); + this.initialized = true + } } setOptions(authOptions: AuthOptions) {