442
443
private async updateRemoteSnippets(resourcePreviews: ISnippetsAcceptedResourcePreview[], remoteUserData: IRemoteUserData, forcePush: boolean): Promise<IRemoteUserData> {
444
>
const currentSnippets: IStringDictionary<string> = remoteUserData.syncData ? this.parseSnippets(remoteUserData.syncData) : {};
snippetsSync.ts
445
>
const newSnippets: IStringDictionary<string> = deepClone(currentSnippets);
446
>
447
>
for (const { acceptResult, localResource, remoteResource, remoteChange } of resourcePreviews) {
448
>
if (remoteChange !== Change.None) {
449
>
const key = localResource ? this.extUri.basename(localResource) : this.extUri.basename(remoteResource);
450
>
if (remoteChange === Change.Deleted) {
451
delete newSnippets[key];
453
>
newSnippets[key] = acceptResult.content!;
454
>
}
455
>
}
456
>
}
457
>
458
>
if (!areSame(currentSnippets, newSnippets)) {
459
>
// update remote
460
>
this.logService.trace(`${this.syncResourceLogLabel}: Updating remote snippets...`);
461
>
remoteUserData = await this.updateRemoteUserData(JSON.stringify(newSnippets), forcePush ? null : remoteUserData.ref);
462
>
this.logService.info(`${this.syncResourceLogLabel}: Updated remote snippets`);
463
>
}
464
>
return remoteUserData;
465
>
}
466
467
private parseSnippets(syncData: ISyncData): IStringDictionary<string> {