initialize only after provider is registered

This commit is contained in:
Sandeep Somavarapu
2020-04-15 19:38:00 +02:00
parent 545c747f0b
commit e408564b74
@@ -57,20 +57,24 @@ export class UserDataSyncAccountManager extends Disposable {
super();
this.userDataSyncAccountProvider = getUserDataSyncStore(productService, configurationService)?.authenticationProviderId;
if (this.userDataSyncAccountProvider) {
this.update();
this._register(
Event.any(
Event.filter(
Event.any(
this.authenticationService.onDidRegisterAuthenticationProvider,
this.authenticationService.onDidUnregisterAuthenticationProvider,
Event.map(this.authenticationService.onDidChangeSessions, e => e.providerId)
), providerId => providerId === this.userDataSyncAccountProvider),
authenticationTokenService.onTokenFailed)
(() => this.update()));
this._register(Event.once(Event.filter(this.authenticationService.onDidRegisterAuthenticationProvider, providerId => providerId === this.userDataSyncAccountProvider))(() => this.initialize()));
}
}
private async initialize(): Promise<void> {
await this.update();
this._register(
Event.any(
Event.filter(
Event.any(
this.authenticationService.onDidRegisterAuthenticationProvider,
this.authenticationService.onDidUnregisterAuthenticationProvider,
Event.map(this.authenticationService.onDidChangeSessions, e => e.providerId)
), providerId => providerId === this.userDataSyncAccountProvider),
this.authenticationTokenService.onTokenFailed)
(() => this.update()));
}
private async update(): Promise<void> {
if (!this.userDataSyncAccountProvider) {
return;