mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-26 11:38:51 +01:00
extract UserDataAutoSyncEnablementService from UserDataAutoSyncService
This commit is contained in:
@@ -3,11 +3,10 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IUserDataAutoSyncService } from 'vs/platform/userDataSync/common/userDataSync';
|
||||
import { UserDataAutoSyncService } from 'vs/platform/userDataSync/common/userDataAutoSyncService';
|
||||
import { UserDataAutoSyncEnablementService } from 'vs/platform/userDataSync/common/userDataAutoSyncService';
|
||||
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
|
||||
|
||||
export class WebUserDataAutoSyncService extends UserDataAutoSyncService implements IUserDataAutoSyncService {
|
||||
export class WebUserDataAutoSyncEnablementService extends UserDataAutoSyncEnablementService {
|
||||
|
||||
private get workbenchEnvironmentService(): IWorkbenchEnvironmentService { return <IWorkbenchEnvironmentService>this.environmentService; }
|
||||
private enabled: boolean | undefined = undefined;
|
||||
@@ -22,7 +21,7 @@ export class WebUserDataAutoSyncService extends UserDataAutoSyncService implemen
|
||||
return this.enabled;
|
||||
}
|
||||
|
||||
protected setEnablement(enabled: boolean) {
|
||||
setEnablement(enabled: boolean) {
|
||||
if (this.enabled !== enabled) {
|
||||
this.enabled = enabled;
|
||||
if (this.workbenchEnvironmentService.options?.settingsSyncOptions) {
|
||||
@@ -3,7 +3,7 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IUserDataSyncService, IAuthenticationProvider, isAuthenticationProvider, IUserDataAutoSyncService, SyncResource, IResourcePreview, ISyncResourcePreview, Change, IManualSyncTask, IUserDataSyncStoreManagementService, SyncStatus } from 'vs/platform/userDataSync/common/userDataSync';
|
||||
import { IUserDataSyncService, IAuthenticationProvider, isAuthenticationProvider, IUserDataAutoSyncService, SyncResource, IResourcePreview, ISyncResourcePreview, Change, IManualSyncTask, IUserDataSyncStoreManagementService, SyncStatus, IUserDataAutoSyncEnablementService } from 'vs/platform/userDataSync/common/userDataSync';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
|
||||
import { IUserDataSyncWorkbenchService, IUserDataSyncAccount, AccountStatus, CONTEXT_SYNC_ENABLEMENT, CONTEXT_SYNC_STATE, CONTEXT_ACCOUNT_STATE, SHOW_SYNC_LOG_COMMAND_ID, getSyncAreaLabel, IUserDataSyncPreview, IUserDataSyncResource, CONTEXT_ENABLE_SYNC_MERGES_VIEW, SYNC_MERGES_VIEW_ID, CONTEXT_ENABLE_ACTIVITY_VIEWS, SYNC_VIEW_CONTAINER_ID, SYNC_TITLE } from 'vs/workbench/services/userDataSync/common/userDataSync';
|
||||
@@ -93,6 +93,7 @@ export class UserDataSyncWorkbenchService extends Disposable implements IUserDat
|
||||
@IUserDataSyncAccountService private readonly userDataSyncAccountService: IUserDataSyncAccountService,
|
||||
@IQuickInputService private readonly quickInputService: IQuickInputService,
|
||||
@IStorageService private readonly storageService: IStorageService,
|
||||
@IUserDataAutoSyncEnablementService private readonly userDataAutoSyncEnablementService: IUserDataAutoSyncEnablementService,
|
||||
@IUserDataAutoSyncService private readonly userDataAutoSyncService: IUserDataAutoSyncService,
|
||||
@ITelemetryService private readonly telemetryService: ITelemetryService,
|
||||
@ILogService private readonly logService: ILogService,
|
||||
@@ -118,8 +119,8 @@ export class UserDataSyncWorkbenchService extends Disposable implements IUserDat
|
||||
if (this.userDataSyncStoreManagementService.userDataSyncStore) {
|
||||
this.syncStatusContext.set(this.userDataSyncService.status);
|
||||
this._register(userDataSyncService.onDidChangeStatus(status => this.syncStatusContext.set(status)));
|
||||
this.syncEnablementContext.set(userDataAutoSyncService.isEnabled());
|
||||
this._register(userDataAutoSyncService.onDidChangeEnablement(enabled => this.syncEnablementContext.set(enabled)));
|
||||
this.syncEnablementContext.set(userDataAutoSyncEnablementService.isEnabled());
|
||||
this._register(userDataAutoSyncEnablementService.onDidChangeEnablement(enabled => this.syncEnablementContext.set(enabled)));
|
||||
|
||||
this.waitAndInitialize();
|
||||
}
|
||||
@@ -247,7 +248,7 @@ export class UserDataSyncWorkbenchService extends Disposable implements IUserDat
|
||||
if (!this.authenticationProviders.length) {
|
||||
throw new Error(localize('no authentication providers', "Settings sync cannot be turned on because there are no authentication providers available."));
|
||||
}
|
||||
if (this.userDataAutoSyncService.isEnabled()) {
|
||||
if (this.userDataAutoSyncEnablementService.isEnabled()) {
|
||||
return;
|
||||
}
|
||||
if (this.userDataSyncService.status !== SyncStatus.Idle) {
|
||||
@@ -552,7 +553,7 @@ export class UserDataSyncWorkbenchService extends Disposable implements IUserDat
|
||||
|
||||
private async switch(sessionId: string, accountName: string, accountId: string): Promise<void> {
|
||||
const currentAccount = this.current;
|
||||
if (this.userDataAutoSyncService.isEnabled() && (currentAccount && currentAccount.accountName !== accountName)) {
|
||||
if (this.userDataAutoSyncEnablementService.isEnabled() && (currentAccount && currentAccount.accountName !== accountName)) {
|
||||
// accounts are switched while sync is enabled.
|
||||
}
|
||||
this.currentSessionId = sessionId;
|
||||
@@ -565,7 +566,7 @@ export class UserDataSyncWorkbenchService extends Disposable implements IUserDat
|
||||
this.currentSessionId = undefined;
|
||||
await this.update();
|
||||
|
||||
if (this.userDataAutoSyncService.isEnabled()) {
|
||||
if (this.userDataAutoSyncEnablementService.isEnabled()) {
|
||||
this.notificationService.notify({
|
||||
severity: Severity.Error,
|
||||
message: localize('successive auth failures', "Settings sync is suspended because of successive authorization failures. Please sign in again to continue synchronizing"),
|
||||
|
||||
@@ -3,16 +3,13 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IUserDataAutoSyncService, UserDataSyncError, IUserDataSyncStoreManagementService } from 'vs/platform/userDataSync/common/userDataSync';
|
||||
import { IUserDataAutoSyncService, UserDataSyncError } from 'vs/platform/userDataSync/common/userDataSync';
|
||||
import { ISharedProcessService } from 'vs/platform/ipc/electron-browser/sharedProcessService';
|
||||
import { IChannel } from 'vs/base/parts/ipc/common/ipc';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { UserDataAutoSyncEnablementService } from 'vs/platform/userDataSync/common/userDataAutoSyncService';
|
||||
import { IStorageService } from 'vs/platform/storage/common/storage';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
|
||||
|
||||
class UserDataAutoSyncService extends UserDataAutoSyncEnablementService implements IUserDataAutoSyncService {
|
||||
class UserDataAutoSyncService implements IUserDataAutoSyncService {
|
||||
|
||||
declare readonly _serviceBrand: undefined;
|
||||
|
||||
@@ -20,12 +17,8 @@ class UserDataAutoSyncService extends UserDataAutoSyncEnablementService implemen
|
||||
get onError(): Event<UserDataSyncError> { return Event.map(this.channel.listen<Error>('onError'), e => UserDataSyncError.toUserDataSyncError(e)); }
|
||||
|
||||
constructor(
|
||||
@IStorageService storageService: IStorageService,
|
||||
@IEnvironmentService environmentService: IEnvironmentService,
|
||||
@IUserDataSyncStoreManagementService userDataSyncStoreManagementService: IUserDataSyncStoreManagementService,
|
||||
@ISharedProcessService sharedProcessService: ISharedProcessService,
|
||||
) {
|
||||
super(storageService, environmentService, userDataSyncStoreManagementService);
|
||||
this.channel = sharedProcessService.getChannel('userDataAutoSync');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user