load ancestors and templates when receiving sync from backend

This commit is contained in:
zadam
2020-03-19 09:18:36 +01:00
parent 48c57c7ce7
commit debce78c7f
4 changed files with 107 additions and 88 deletions

View File

@@ -203,6 +203,25 @@ subscribeToMessages(message => {
});
async function processSyncRows(syncRows) {
const missingNoteIds = [];
syncRows.forEach(({entityName, entity}) => {
if (entityName === 'branches' && !(entity.parentNoteId in treeCache.notes)) {
missingNoteIds.push(entity.parentNoteId);
}
else if (entityName === 'attributes'
&& entity.type === 'relation'
&& entity.name === 'template'
&& !(entity.noteId in treeCache.notes)) {
missingNoteIds.push(entity.value);
}
});
if (missingNoteIds.length > 0) {
await treeCache.reloadNotes(missingNoteIds);
}
const loadResults = new LoadResults(treeCache);
syncRows.filter(sync => sync.entityName === 'notes').forEach(sync => {