44 *--------------------------------------------------------------------------------------------*/
55
66import { IWorkbenchContributionsRegistry , Extensions as WorkbenchExtensions , IWorkbenchContribution } from 'vs/workbench/common/contributions' ;
7- import { IUserDataSyncService , SyncStatus , USER_DATA_PREVIEW_SCHEME } from 'vs/workbench/services/userData/common/userData' ;
7+ import { IUserDataSyncService , SyncStatus , USER_DATA_PREVIEW_SCHEME , IRemoteUserDataService } from 'vs/workbench/services/userData/common/userData' ;
88import { localize } from 'vs/nls' ;
99import { Disposable , MutableDisposable , toDisposable } from 'vs/base/common/lifecycle' ;
1010import { CommandsRegistry } from 'vs/platform/commands/common/commands' ;
@@ -37,7 +37,7 @@ Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration)
3737 'userConfiguration.enableSync' : {
3838 type : 'boolean' ,
3939 description : localize ( 'userConfiguration.enableSync' , "When enabled, synchronises User Configuration: Settings, Keybindings, Extensions & Snippets." ) ,
40- default : false ,
40+ default : true ,
4141 scope : ConfigurationScope . APPLICATION
4242 }
4343 }
@@ -48,25 +48,23 @@ class UserDataSyncContribution extends Disposable implements IWorkbenchContribut
4848 constructor (
4949 @IConfigurationService private readonly configurationService : IConfigurationService ,
5050 @IUserDataSyncService private readonly userDataSyncService : IUserDataSyncService ,
51+ @IRemoteUserDataService private readonly remoteUserDataService : IRemoteUserDataService ,
5152 ) {
5253 super ( ) ;
5354 this . loopSync ( ) ;
54- this . _register ( Event . filter ( this . configurationService . onDidChangeConfiguration ,
55- e => e . affectsConfiguration ( 'userConfiguration.enableSync' ) && this . configurationService . getValue < boolean > ( 'userConfiguration.enableSync' ) )
56- ( ( ) => this . sync ( ) ) ) ;
55+ this . _register ( Event . any < any > (
56+ Event . filter ( this . configurationService . onDidChangeConfiguration , e => e . affectsConfiguration ( 'userConfiguration.enableSync' ) && this . configurationService . getValue < boolean > ( 'userConfiguration.enableSync' ) ) ,
57+ this . remoteUserDataService . onDidChangeEnablement )
58+ ( ( ) => this . loopSync ( ) ) ) ;
5759 }
5860
5961 private loopSync ( ) : void {
60- this . sync ( )
61- . then ( ( ) => timeout ( 500 ) )
62- . then ( ( ) => this . loopSync ( ) ) ;
63- }
64-
65- private sync ( ) : Promise < any > {
66- if ( this . userDataSyncService . status === SyncStatus . Idle && this . configurationService . getValue < boolean > ( 'userConfiguration.enableSync' ) ) {
67- return this . userDataSyncService . sync ( ) ;
62+ if ( this . configurationService . getValue < boolean > ( 'userConfiguration.enableSync' ) && this . remoteUserDataService . isEnabled ( ) ) {
63+ this . userDataSyncService . sync ( )
64+ . then ( null , ( ) => null ) // Surpress errors
65+ . then ( ( ) => timeout ( 500 ) )
66+ . then ( ( ) => this . loopSync ( ) ) ;
6867 }
69- return Promise . resolve ( ) ;
7068 }
7169
7270}
@@ -91,7 +89,7 @@ class SyncActionsContribution extends Disposable implements IWorkbenchContributi
9189 super ( ) ;
9290 this . syncEnablementContext = CONTEXT_SYNC_STATE . bindTo ( contextKeyService ) ;
9391 this . onDidChangeStatus ( userDataSyncService . status ) ;
94- this . _register ( userDataSyncService . onDidChangeStatus ( status => this . onDidChangeStatus ( status ) ) ) ;
92+ this . _register ( Event . debounce ( userDataSyncService . onDidChangeStatus , ( ) => undefined , 500 ) ( status => this . onDidChangeStatus ( userDataSyncService . status ) ) ) ;
9593 this . registerActions ( ) ;
9694 }
9795
0 commit comments