From 5b8f78a157084677dbbd327f6c68ece96c9da456 Mon Sep 17 00:00:00 2001 From: Jackson Kearl Date: Fri, 15 Jan 2021 08:56:34 -0800 Subject: [PATCH] Move sync-enabled trigger to gettingStartedService --- .../userDataSync/browser/userDataSync.ts | 8 ++------ .../common/gettingStartedService.ts | 19 ++++++++++++++----- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/vs/workbench/contrib/userDataSync/browser/userDataSync.ts b/src/vs/workbench/contrib/userDataSync/browser/userDataSync.ts index 03d6e9310a0..0d60cf462ef 100644 --- a/src/vs/workbench/contrib/userDataSync/browser/userDataSync.ts +++ b/src/vs/workbench/contrib/userDataSync/browser/userDataSync.ts @@ -54,7 +54,6 @@ import { UserDataSyncDataViews } from 'vs/workbench/contrib/userDataSync/browser import { IUserDataSyncWorkbenchService, getSyncAreaLabel, AccountStatus, CONTEXT_SYNC_STATE, CONTEXT_SYNC_ENABLEMENT, CONTEXT_ACCOUNT_STATE, CONFIGURE_SYNC_COMMAND_ID, SHOW_SYNC_LOG_COMMAND_ID, SYNC_VIEW_CONTAINER_ID, SYNC_TITLE, SYNC_VIEW_ICON } from 'vs/workbench/services/userDataSync/common/userDataSync'; import { Codicon } from 'vs/base/common/codicons'; import { ViewPaneContainer } from 'vs/workbench/browser/parts/views/viewPaneContainer'; -import { IGettingStartedService } from 'vs/workbench/services/gettingStarted/common/gettingStartedService'; const CONTEXT_CONFLICTS_SOURCES = new RawContextKey('conflictsSources', ''); @@ -118,7 +117,6 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo @ITelemetryService private readonly telemetryService: ITelemetryService, @IProductService private readonly productService: IProductService, @IStorageService private readonly storageService: IStorageService, - @IGettingStartedService private readonly gettingStartedService: IGettingStartedService, @IOpenerService private readonly openerService: IOpenerService, @IAuthenticationService private readonly authenticationService: IAuthenticationService, @IUserDataSyncStoreManagementService private readonly userDataSyncStoreManagementService: IUserDataSyncStoreManagementService, @@ -155,10 +153,8 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo textModelResolverService.registerTextModelContentProvider(USER_DATA_SYNC_SCHEME, instantiationService.createInstance(UserDataRemoteContentProvider)); registerEditorContribution(AcceptChangesContribution.ID, AcceptChangesContribution); - this._register(Event.any(userDataSyncService.onDidChangeStatus, userDataAutoSyncEnablementService.onDidChangeEnablement)(() => { - if (userDataAutoSyncEnablementService.isEnabled()) { this.gettingStartedService.progressByEvent('sync-enabled'); } - this.turningOnSync = !userDataAutoSyncEnablementService.isEnabled() && userDataSyncService.status !== SyncStatus.Idle; - })); + this._register(Event.any(userDataSyncService.onDidChangeStatus, userDataAutoSyncEnablementService.onDidChangeEnablement) + (() => this.turningOnSync = !userDataAutoSyncEnablementService.isEnabled() && userDataSyncService.status !== SyncStatus.Idle)); } } diff --git a/src/vs/workbench/services/gettingStarted/common/gettingStartedService.ts b/src/vs/workbench/services/gettingStarted/common/gettingStartedService.ts index 243926c63d7..b5784ee9ddb 100644 --- a/src/vs/workbench/services/gettingStarted/common/gettingStartedService.ts +++ b/src/vs/workbench/services/gettingStarted/common/gettingStartedService.ts @@ -12,6 +12,8 @@ import { Memento } from 'vs/workbench/common/memento'; import { Action2, registerAction2 } from 'vs/platform/actions/common/actions'; import { ICommandService } from 'vs/platform/commands/common/commands'; import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; +import { Disposable } from 'vs/base/common/lifecycle'; +import { IUserDataAutoSyncEnablementService } from 'vs/platform/userDataSync/common/userDataSync'; export const IGettingStartedService = createDecorator('gettingStartedService'); @@ -43,7 +45,7 @@ export interface IGettingStartedService { progressByEvent(eventName: string): void; } -export class GettingStartedService implements IGettingStartedService { +export class GettingStartedService extends Disposable implements IGettingStartedService { declare readonly _serviceBrand: undefined; private readonly _onDidAddTask = new Emitter(); @@ -65,7 +67,10 @@ export class GettingStartedService implements IGettingStartedService { @IStorageService private readonly storageService: IStorageService, @ICommandService private readonly commandService: ICommandService, @IContextKeyService private readonly contextService: IContextKeyService, + @IUserDataAutoSyncEnablementService readonly userDataAutoSyncEnablementService: IUserDataAutoSyncEnablementService, ) { + super(); + this.memento = new Memento('gettingStartedService', this.storageService); this.taskProgress = this.memento.getMemento(StorageScope.GLOBAL, StorageTarget.USER); @@ -75,13 +80,17 @@ export class GettingStartedService implements IGettingStartedService { } }); - this.registry.onDidAddCategory(category => this._onDidAddCategory.fire(this.getCategoryProgress(category))); - this.registry.onDidAddTask(task => { + this._register(this.registry.onDidAddCategory(category => this._onDidAddCategory.fire(this.getCategoryProgress(category)))); + this._register(this.registry.onDidAddTask(task => { this.registerDoneListeners(task); this._onDidAddTask.fire(this.getTaskProgress(task)); - }); + })); + + this._register(this.commandService.onDidExecuteCommand(command => this.progressByCommand(command.commandId))); - this.commandService.onDidExecuteCommand(command => this.progressByCommand(command.commandId)); + this._register(userDataAutoSyncEnablementService.onDidChangeEnablement(() => { + if (userDataAutoSyncEnablementService.isEnabled()) { this.progressByEvent('sync-enabled'); } + })); } private registerDoneListeners(task: IGettingStartedTask) { -- GitLab