#95879 Rename to IUserDataSyncAccountService

This commit is contained in:
Sandeep Somavarapu
2020-06-09 10:36:29 +02:00
parent 58e840c373
commit 8f70ac449e
16 changed files with 114 additions and 124 deletions

View File

@@ -13,7 +13,7 @@ import { Emitter, Event } from 'vs/base/common/event';
import { flatten } from 'vs/base/common/arrays';
import { values } from 'vs/base/common/map';
import { IAuthenticationService } from 'vs/workbench/services/authentication/browser/authenticationService';
import { IAuthenticationTokenService } from 'vs/platform/authentication/common/authentication';
import { IUserDataSyncAccountService } from 'vs/platform/userDataSync/common/userDataSyncAccount';
import { IQuickInputService, IQuickPickSeparator } from 'vs/platform/quickinput/common/quickInput';
import { IStorageService, IWorkspaceStorageChangeEvent, StorageScope } from 'vs/platform/storage/common/storage';
import { ILogService } from 'vs/platform/log/common/log';
@@ -78,7 +78,7 @@ export class UserDataSyncWorkbenchService extends Disposable implements IUserDat
constructor(
@IUserDataSyncService private readonly userDataSyncService: IUserDataSyncService,
@IAuthenticationService private readonly authenticationService: IAuthenticationService,
@IAuthenticationTokenService private readonly authenticationTokenService: IAuthenticationTokenService,
@IUserDataSyncAccountService private readonly userDataSyncAccountService: IUserDataSyncAccountService,
@IQuickInputService private readonly quickInputService: IQuickInputService,
@IStorageService private readonly storageService: IStorageService,
@IUserDataSyncEnablementService private readonly userDataSyncEnablementService: IUserDataSyncEnablementService,
@@ -137,7 +137,7 @@ export class UserDataSyncWorkbenchService extends Disposable implements IUserDat
this.authenticationService.onDidRegisterAuthenticationProvider,
this.authenticationService.onDidUnregisterAuthenticationProvider,
), authenticationProviderId => this.isSupportedAuthenticationProviderId(authenticationProviderId)),
this.authenticationTokenService.onTokenFailed)
this.userDataSyncAccountService.onTokenFailed)
(() => this.update()));
this._register(Event.filter(this.authenticationService.onDidChangeSessions, e => this.isSupportedAuthenticationProviderId(e.providerId))(({ event }) => this.onDidChangeSessions(event)));
@@ -190,7 +190,7 @@ export class UserDataSyncWorkbenchService extends Disposable implements IUserDat
this.logService.error(e);
}
}
await this.authenticationTokenService.setToken(value);
await this.userDataSyncAccountService.updateAccount(value);
}
private updateAccountStatus(current: UserDataSyncAccount | undefined): void {

View File

@@ -0,0 +1,45 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { IChannel } from 'vs/base/parts/ipc/common/ipc';
import { ISharedProcessService } from 'vs/platform/ipc/electron-browser/sharedProcessService';
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { Disposable } from 'vs/base/common/lifecycle';
import { Emitter, Event } from 'vs/base/common/event';
import { IUserDataSyncAccountService, IUserDataSyncAccount } from 'vs/platform/userDataSync/common/userDataSyncAccount';
export class UserDataSyncAccountService extends Disposable implements IUserDataSyncAccountService {
declare readonly _serviceBrand: undefined;
private readonly channel: IChannel;
private _token: IUserDataSyncAccount | undefined;
get account(): IUserDataSyncAccount | undefined { return this._token; }
private _onDidChangeToken = this._register(new Emitter<IUserDataSyncAccount | undefined>());
readonly onDidChangeAccount = this._onDidChangeToken.event;
private _onTokenFailed: Emitter<void> = this._register(new Emitter<void>());
readonly onTokenFailed: Event<void> = this._onTokenFailed.event;
constructor(
@ISharedProcessService sharedProcessService: ISharedProcessService,
) {
super();
this.channel = sharedProcessService.getChannel('userDataSyncAccount');
this._register(this.channel.listen<void[]>('onTokenFailed')(_ => this.sendTokenFailed()));
}
updateAccount(account: IUserDataSyncAccount | undefined): Promise<undefined> {
this._token = account;
return this.channel.call('updateAccount', account);
}
sendTokenFailed(): void {
this._onTokenFailed.fire();
}
}
registerSingleton(IUserDataSyncAccountService, UserDataSyncAccountService);