80
81
protected async generateSyncPreview(remoteUserData: IRemoteUserData, lastSyncUserData: IRemoteUserData | null, isRemoteDataFromCurrentMachine: boolean): Promise<IPromptsResourcePreview[]> {
82
>
const local = await this.getPromptsFileContents();
promptsSync.ts
83
>
const localPrompts = this.toPromptContents(local);
84
>
const remotePrompts: IStringDictionary<string> | null = remoteUserData.syncData ? this.parsePrompts(remoteUserData.syncData) : null;
85
>
86
>
// Use remote data as last sync data if last sync data does not exist and remote data is from same machine
87
>
lastSyncUserData = lastSyncUserData === null && isRemoteDataFromCurrentMachine ? remoteUserData : lastSyncUserData;
88
>
const lastSyncPrompts: IStringDictionary<string> | null = lastSyncUserData && lastSyncUserData.syncData ? this.parsePrompts(lastSyncUserData.syncData) : null;
89
>
90
>
if (remotePrompts) {
91
this.logService.trace(`${this.syncResourceLogLabel}: Merging remote prompts with local prompts...`);
93
>
this.logService.trace(`${this.syncResourceLogLabel}: Remote prompts does not exist. Synchronizing prompts for the first time.`);
94
>
}
95
>
96
>
const mergeResult = merge(localPrompts, remotePrompts, lastSyncPrompts);
97
>
return this.getResourcePreviews(mergeResult, local, remotePrompts || {}, lastSyncPrompts || {});
98
>
}
99
100
protected async hasRemoteChanged(lastSyncUserData: IRemoteUserData): Promise<boolean> {