提交 9964824e 编写于 作者: S Sandeep Somavarapu

do not stop if it was not running before

上级 8d9356ea
...@@ -131,27 +131,32 @@ export class UserDataAutoSync extends Disposable { ...@@ -131,27 +131,32 @@ export class UserDataAutoSync extends Disposable {
@IAuthTokenService private readonly authTokenService: IAuthTokenService, @IAuthTokenService private readonly authTokenService: IAuthTokenService,
) { ) {
super(); super();
this.updateEnablement(); this.updateEnablement(false);
this.sync(true); this._register(Event.any<any>(authTokenService.onDidChangeStatus, userDataSyncService.onDidChangeStatus)(() => this.updateEnablement(true)));
this._register(Event.any<any>(authTokenService.onDidChangeStatus, userDataSyncService.onDidChangeStatus)(() => this.updateEnablement())); this._register(Event.filter(this.configurationService.onDidChangeConfiguration, e => e.affectsConfiguration('configurationSync.enable'))(() => this.updateEnablement(true)));
this._register(Event.filter(this.configurationService.onDidChangeConfiguration, e => e.affectsConfiguration('configurationSync.enable'))(() => this.updateEnablement()));
// Sync immediately if there is a local change. // Sync immediately if there is a local change.
this._register(Event.debounce(this.userDataSyncService.onDidChangeLocal, () => undefined, 500)(() => this.sync(false))); this._register(Event.debounce(this.userDataSyncService.onDidChangeLocal, () => undefined, 500)(() => this.sync(false)));
} }
private updateEnablement(): void { private updateEnablement(stopIfDisabled: boolean): void {
const enabled = this.isSyncEnabled(); const enabled = this.isSyncEnabled();
if (this.enabled !== enabled) { if (this.enabled === enabled) {
this.enabled = enabled; return;
if (this.enabled) { }
this.userDataSyncLogService.info('Syncing configuration started');
this.sync(true); this.enabled = enabled;
} else { if (this.enabled) {
this.userDataSyncLogService.info('Syncing configuration started');
this.sync(true);
return;
} else {
if (stopIfDisabled) {
this.userDataSyncService.stop(); this.userDataSyncService.stop();
this.userDataSyncLogService.info('Syncing configuration stopped.'); this.userDataSyncLogService.info('Syncing configuration stopped.');
} }
} }
} }
private async sync(loop: boolean): Promise<void> { private async sync(loop: boolean): Promise<void> {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册