Skip to content

Commit

Permalink
Auto sync in web
Browse files Browse the repository at this point in the history
  • Loading branch information
sandy081 committed Sep 17, 2019
1 parent 6b2da9b commit f476676
Showing 1 changed file with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ import { Event } from 'vs/base/common/event';
import { IHistoryService } from 'vs/workbench/services/history/common/history';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
import { isEqual } from 'vs/base/common/resources';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { isWeb } from 'vs/base/common/platform';
import { UserDataAutoSync } from 'vs/platform/userDataSync/common/userDataSyncService';

const CONTEXT_SYNC_STATE = new RawContextKey<string>('syncStatus', SyncStatus.Uninitialized);

Expand All @@ -45,6 +48,18 @@ Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration)
}
});

class UserDataAutoSyncContribution extends Disposable implements IWorkbenchContribution {

constructor(
@IInstantiationService instantiationService: IInstantiationService
) {
super();
if (isWeb) {
instantiationService.createInstance(UserDataAutoSync);
}
}
}

const SYNC_PUSH_LIGHT_ICON_URI = URI.parse(registerAndGetAmdImageURL(`vs/workbench/contrib/userData/browser/media/sync-push-light.svg`));
const SYNC_PUSH_DARK_ICON_URI = URI.parse(registerAndGetAmdImageURL(`vs/workbench/contrib/userData/browser/media/sync-push-dark.svg`));
class SyncActionsContribution extends Disposable implements IWorkbenchContribution {
Expand Down Expand Up @@ -128,7 +143,7 @@ class SyncActionsContribution extends Disposable implements IWorkbenchContributi
}

private async handleConflicts(): Promise<void> {
if (this.userDataSyncService.conflictsSource === SyncSource.Settings ) {
if (this.userDataSyncService.conflictsSource === SyncSource.Settings) {
const resourceInput = {
resource: this.workbenchEnvironmentService.settingsSyncPreviewResource,
options: {
Expand Down Expand Up @@ -207,3 +222,4 @@ class SyncActionsContribution extends Disposable implements IWorkbenchContributi

const workbenchRegistry = Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench);
workbenchRegistry.registerWorkbenchContribution(SyncActionsContribution, LifecyclePhase.Starting);
workbenchRegistry.registerWorkbenchContribution(UserDataAutoSyncContribution, LifecyclePhase.Restored);

0 comments on commit f476676

Please sign in to comment.