60
61
protected async generateSyncPreview(remoteUserData: IRemoteUserData, lastSyncUserData: IRemoteUserData | null, isRemoteDataFromCurrentMachine: boolean): Promise<ISnippetsResourcePreview[]> {
63
>
const localSnippets = this.toSnippetsContents(local);
64
>
const remoteSnippets: IStringDictionary<string> | null = remoteUserData.syncData ? this.parseSnippets(remoteUserData.syncData) : null;
65
>
66
>
// Use remote data as last sync data if last sync data does not exist and remote data is from same machine
67
>
lastSyncUserData = lastSyncUserData === null && isRemoteDataFromCurrentMachine ? remoteUserData : lastSyncUserData;
68
>
const lastSyncSnippets: IStringDictionary<string> | null = lastSyncUserData && lastSyncUserData.syncData ? this.parseSnippets(lastSyncUserData.syncData) : null;
69
>
70
>
if (remoteSnippets) {
71
this.logService.trace(`${this.syncResourceLogLabel}: Merging remote snippets with local snippets...`);
73
>
this.logService.trace(`${this.syncResourceLogLabel}: Remote snippets does not exist. Synchronizing snippets for the first time.`);
74
>
}
75
>
76
>
const mergeResult = merge(localSnippets, remoteSnippets, lastSyncSnippets);
77
>
return this.getResourcePreviews(mergeResult, local, remoteSnippets || {}, lastSyncSnippets || {});
78
>
}
79
80
protected async hasRemoteChanged(lastSyncUserData: IRemoteUserData): Promise<boolean> {