- do not block sync if there are conflicts in one area

- allow confilicts in multiple areas
This commit is contained in:
Sandeep Somavarapu
2020-02-09 10:57:03 +01:00
parent 6a72d1a519
commit fd2705396f
5 changed files with 152 additions and 108 deletions

View File

@@ -24,8 +24,10 @@ export class UserDataSyncService extends Disposable implements IUserDataSyncServ
get onDidChangeLocal(): Event<void> { return this.channel.listen('onDidChangeLocal'); }
private _conflictsSource: SyncSource | null = null;
get conflictsSource(): SyncSource | null { return this._conflictsSource; }
private _conflictsSources: SyncSource[] = [];
get conflictsSources(): SyncSource[] { return this._conflictsSources; }
private _onDidChangeConflicts: Emitter<SyncSource[]> = this._register(new Emitter<SyncSource[]>());
readonly onDidChangeConflicts: Event<SyncSource[]> = this._onDidChangeConflicts.event;
constructor(
@ISharedProcessService sharedProcessService: ISharedProcessService
@@ -41,10 +43,12 @@ export class UserDataSyncService extends Disposable implements IUserDataSyncServ
return userDataSyncChannel.listen(event, arg);
}
};
this.channel.call<SyncStatus>('_getInitialStatus').then(status => {
this.channel.call<[SyncStatus, SyncSource[]]>('_getInitialData').then(([status, conflicts]) => {
this.updateStatus(status);
this.updateConflicts(conflicts);
this._register(this.channel.listen<SyncStatus>('onDidChangeStatus')(status => this.updateStatus(status)));
});
this._register(this.channel.listen<SyncSource[]>('onDidChangeConflicts')(conflicts => this.updateConflicts(conflicts)));
}
pull(): Promise<void> {
@@ -75,8 +79,8 @@ export class UserDataSyncService extends Disposable implements IUserDataSyncServ
return this.channel.call('stop');
}
async restart(): Promise<void> {
const status = await this.channel.call<SyncStatus>('restart');
async restart(source: SyncSource): Promise<void> {
const status = await this.channel.call<SyncStatus>('restart', [source]);
await this.updateStatus(status);
}
@@ -101,11 +105,15 @@ export class UserDataSyncService extends Disposable implements IUserDataSyncServ
}
private async updateStatus(status: SyncStatus): Promise<void> {
this._conflictsSource = await this.channel.call<SyncSource>('getConflictsSource');
this._status = status;
this._onDidChangeStatus.fire(status);
}
private async updateConflicts(conflicts: SyncSource[]): Promise<void> {
this._conflictsSources = conflicts;
this._onDidChangeConflicts.fire(conflicts);
}
}
registerSingleton(IUserDataSyncService, UserDataSyncService);