44 *--------------------------------------------------------------------------------------------*/
55
66import { IWorkbenchContribution } from 'vs/workbench/common/contributions' ;
7- import { IUserDataSyncService , SyncStatus , SyncSource , CONTEXT_SYNC_STATE } from 'vs/platform/userDataSync/common/userDataSync' ;
7+ import { IUserDataSyncService , SyncStatus , SyncSource , CONTEXT_SYNC_STATE , IUserDataSyncStore , registerConfiguration , getUserDataSyncStore } from 'vs/platform/userDataSync/common/userDataSync' ;
88import { localize } from 'vs/nls' ;
99import { Disposable , MutableDisposable , toDisposable , DisposableStore } from 'vs/base/common/lifecycle' ;
1010import { CommandsRegistry } from 'vs/platform/commands/common/commands' ;
@@ -29,7 +29,9 @@ import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
2929import { FalseContext } from 'vs/platform/contextkey/common/contextkeys' ;
3030import { IStorageService , StorageScope } from 'vs/platform/storage/common/storage' ;
3131import { IQuickInputService } from 'vs/platform/quickinput/common/quickInput' ;
32- import { IProductService } from 'vs/platform/product/common/productService' ;
32+ import { isWeb } from 'vs/base/common/platform' ;
33+ import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation' ;
34+ import { UserDataAutoSync } from 'vs/platform/userDataSync/common/userDataSyncService' ;
3335
3436const CONTEXT_AUTH_TOKEN_STATE = new RawContextKey < string > ( 'authTokenStatus' , AuthTokenStatus . SignedOut ) ;
3537const SYNC_PUSH_LIGHT_ICON_URI = URI . parse ( registerAndGetAmdImageURL ( `vs/workbench/contrib/userDataSync/browser/media/check-light.svg` ) ) ;
@@ -39,6 +41,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
3941
4042 private static readonly ENABLEMENT_SETTING = 'configurationSync.enable' ;
4143
44+ private readonly userDataSyncStore : IUserDataSyncStore | undefined ;
4245 private readonly syncStatusContext : IContextKey < string > ;
4346 private readonly authTokenContext : IContextKey < string > ;
4447 private readonly badgeDisposable = this . _register ( new MutableDisposable ( ) ) ;
@@ -59,18 +62,26 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
5962 @IDialogService private readonly dialogService : IDialogService ,
6063 @IStorageService private readonly storageService : IStorageService ,
6164 @IQuickInputService private readonly quickInputService : IQuickInputService ,
62- @IProductService private readonly productService : IProductService ,
65+ @IInstantiationService instantiationService : IInstantiationService ,
6366 ) {
6467 super ( ) ;
68+ this . userDataSyncStore = getUserDataSyncStore ( configurationService ) ;
6569 this . syncStatusContext = CONTEXT_SYNC_STATE . bindTo ( contextKeyService ) ;
6670 this . authTokenContext = CONTEXT_AUTH_TOKEN_STATE . bindTo ( contextKeyService ) ;
6771
68- this . onDidChangeAuthTokenStatus ( this . authTokenService . status ) ;
69- this . onDidChangeSyncStatus ( this . userDataSyncService . status ) ;
70- this . _register ( Event . debounce ( authTokenService . onDidChangeStatus , ( ) => undefined , 500 ) ( ( ) => this . onDidChangeAuthTokenStatus ( this . authTokenService . status ) ) ) ;
71- this . _register ( Event . debounce ( userDataSyncService . onDidChangeStatus , ( ) => undefined , 500 ) ( ( ) => this . onDidChangeSyncStatus ( this . userDataSyncService . status ) ) ) ;
72- this . _register ( Event . filter ( this . configurationService . onDidChangeConfiguration , e => e . affectsConfiguration ( UserDataSyncWorkbenchContribution . ENABLEMENT_SETTING ) ) ( ( ) => this . onDidChangeEnablement ( ) ) ) ;
73- this . registerActions ( ) ;
72+ if ( this . userDataSyncStore ) {
73+ registerConfiguration ( ) ;
74+ this . onDidChangeAuthTokenStatus ( this . authTokenService . status ) ;
75+ this . onDidChangeSyncStatus ( this . userDataSyncService . status ) ;
76+ this . _register ( Event . debounce ( authTokenService . onDidChangeStatus , ( ) => undefined , 500 ) ( ( ) => this . onDidChangeAuthTokenStatus ( this . authTokenService . status ) ) ) ;
77+ this . _register ( Event . debounce ( userDataSyncService . onDidChangeStatus , ( ) => undefined , 500 ) ( ( ) => this . onDidChangeSyncStatus ( this . userDataSyncService . status ) ) ) ;
78+ this . _register ( Event . filter ( this . configurationService . onDidChangeConfiguration , e => e . affectsConfiguration ( UserDataSyncWorkbenchContribution . ENABLEMENT_SETTING ) ) ( ( ) => this . onDidChangeEnablement ( ) ) ) ;
79+ this . registerActions ( ) ;
80+
81+ if ( isWeb ) {
82+ this . _register ( instantiationService . createInstance ( UserDataAutoSync ) ) ;
83+ }
84+ }
7485 }
7586
7687 private onDidChangeAuthTokenStatus ( status : AuthTokenStatus ) {
@@ -112,7 +123,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
112123 const enabled = this . configurationService . getValue < boolean > ( UserDataSyncWorkbenchContribution . ENABLEMENT_SETTING ) ;
113124 if ( enabled ) {
114125 if ( this . authTokenService . status === AuthTokenStatus . SignedOut ) {
115- const handle = this . notificationService . prompt ( Severity . Info , localize ( 'ask to sign in' , "Please sign in with your {0} account to sync configuration across all your machines" , this . productService . settingsSyncStore ! . account ) ,
126+ const handle = this . notificationService . prompt ( Severity . Info , localize ( 'ask to sign in' , "Please sign in with your {0} account to sync configuration across all your machines" , this . userDataSyncStore ! . account ) ,
116127 [
117128 {
118129 label : localize ( 'Sign in' , "Sign in" ) ,
@@ -154,8 +165,8 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
154165 if ( this . authTokenService . status === AuthTokenStatus . SignedOut ) {
155166 const result = await this . dialogService . confirm ( {
156167 type : 'info' ,
157- message : localize ( 'sign in to account' , "Sign in to {0}" , this . productService . settingsSyncStore ! . name ) ,
158- detail : localize ( 'ask to sign in' , "Please sign in with your {0} account to sync configuration across all your machines" , this . productService . settingsSyncStore ! . account ) ,
168+ message : localize ( 'sign in to account' , "Sign in to {0}" , this . userDataSyncStore ! . name ) ,
169+ detail : localize ( 'ask to sign in' , "Please sign in with your {0} account to sync configuration across all your machines" , this . userDataSyncStore ! . account ) ,
159170 primaryButton : localize ( 'Sign in' , "Sign in" )
160171 } ) ;
161172 if ( ! result . confirmed ) {
0 commit comments