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

@ -1039,7 +1039,7 @@
<h4 class="name" id="getAttribute"><span class="type-signature">(async) </span>getAttribute<span class="signature">(type, name)</span><span class="type-signature"> &rarr; {Promise.&lt;<a href="Attribute.html">Attribute</a>>}</span></h4> <h4 class="name" id="getAttribute"><span class="type-signature"></span>getAttribute<span class="signature">(type, name)</span><span class="type-signature"> &rarr; {<a href="Attribute.html">Attribute</a>}</span></h4>
@ -1199,7 +1199,7 @@
</dt> </dt>
<dd> <dd>
<span class="param-type">Promise.&lt;<a href="Attribute.html">Attribute</a>></span> <span class="param-type"><a href="Attribute.html">Attribute</a></span>
</dd> </dd>
@ -1217,7 +1217,7 @@
<h4 class="name" id="getAttributes"><span class="type-signature">(async) </span>getAttributes<span class="signature">(type<span class="signature-attributes">opt</span>, name<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Promise.&lt;Array.&lt;<a href="Attribute.html">Attribute</a>>>}</span></h4> <h4 class="name" id="getAttributes"><span class="type-signature"></span>getAttributes<span class="signature">(type<span class="signature-attributes">opt</span>, name<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Array.&lt;<a href="Attribute.html">Attribute</a>>}</span></h4>
@ -1399,7 +1399,7 @@
</dt> </dt>
<dd> <dd>
<span class="param-type">Promise.&lt;Array.&lt;<a href="Attribute.html">Attribute</a>>></span> <span class="param-type">Array.&lt;<a href="Attribute.html">Attribute</a>></span>
</dd> </dd>
@ -1417,7 +1417,7 @@
<h4 class="name" id="getAttributeValue"><span class="type-signature">(async) </span>getAttributeValue<span class="signature">(type, name)</span><span class="type-signature"> &rarr; {Promise.&lt;string>}</span></h4> <h4 class="name" id="getAttributeValue"><span class="type-signature"></span>getAttributeValue<span class="signature">(type, name)</span><span class="type-signature"> &rarr; {string}</span></h4>
@ -1577,7 +1577,7 @@
</dt> </dt>
<dd> <dd>
<span class="param-type">Promise.&lt;string></span> <span class="param-type">string</span>
</dd> </dd>
@ -1595,7 +1595,7 @@
<h4 class="name" id="getBranches"><span class="type-signature">(async) </span>getBranches<span class="signature">()</span><span class="type-signature"> &rarr; {Promise.&lt;Array.&lt;<a href="Branch.html">Branch</a>>>}</span></h4> <h4 class="name" id="getBranches"><span class="type-signature"></span>getBranches<span class="signature">()</span><span class="type-signature"> &rarr; {Array.&lt;<a href="Branch.html">Branch</a>>}</span></h4>
@ -1679,7 +1679,7 @@
</dt> </dt>
<dd> <dd>
<span class="param-type">Promise.&lt;Array.&lt;<a href="Branch.html">Branch</a>>></span> <span class="param-type">Array.&lt;<a href="Branch.html">Branch</a>></span>
</dd> </dd>
@ -1799,7 +1799,7 @@
<h4 class="name" id="getChildBranches"><span class="type-signature">(async) </span>getChildBranches<span class="signature">()</span><span class="type-signature"> &rarr; {Promise.&lt;Array.&lt;<a href="Branch.html">Branch</a>>>}</span></h4> <h4 class="name" id="getChildBranches"><span class="type-signature"></span>getChildBranches<span class="signature">()</span><span class="type-signature"> &rarr; {Array.&lt;<a href="Branch.html">Branch</a>>}</span></h4>
@ -1883,7 +1883,7 @@
</dt> </dt>
<dd> <dd>
<span class="param-type">Promise.&lt;Array.&lt;<a href="Branch.html">Branch</a>>></span> <span class="param-type">Array.&lt;<a href="Branch.html">Branch</a>></span>
</dd> </dd>
@ -2105,7 +2105,7 @@
<h4 class="name" id="getLabel"><span class="type-signature">(async) </span>getLabel<span class="signature">(name)</span><span class="type-signature"> &rarr; {Promise.&lt;<a href="Attribute.html">Attribute</a>>}</span></h4> <h4 class="name" id="getLabel"><span class="type-signature"></span>getLabel<span class="signature">(name)</span><span class="type-signature"> &rarr; {<a href="Attribute.html">Attribute</a>}</span></h4>
@ -2242,7 +2242,7 @@
</dt> </dt>
<dd> <dd>
<span class="param-type">Promise.&lt;<a href="Attribute.html">Attribute</a>></span> <span class="param-type"><a href="Attribute.html">Attribute</a></span>
</dd> </dd>
@ -2260,7 +2260,7 @@
<h4 class="name" id="getLabelDefinitions"><span class="type-signature">(async) </span>getLabelDefinitions<span class="signature">(name<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Promise.&lt;Array.&lt;<a href="Attribute.html">Attribute</a>>>}</span></h4> <h4 class="name" id="getLabelDefinitions"><span class="type-signature"></span>getLabelDefinitions<span class="signature">(name<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Array.&lt;<a href="Attribute.html">Attribute</a>>}</span></h4>
@ -2409,7 +2409,7 @@
</dt> </dt>
<dd> <dd>
<span class="param-type">Promise.&lt;Array.&lt;<a href="Attribute.html">Attribute</a>>></span> <span class="param-type">Array.&lt;<a href="Attribute.html">Attribute</a>></span>
</dd> </dd>
@ -2427,7 +2427,7 @@
<h4 class="name" id="getLabels"><span class="type-signature">(async) </span>getLabels<span class="signature">(name<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Promise.&lt;Array.&lt;<a href="Attribute.html">Attribute</a>>>}</span></h4> <h4 class="name" id="getLabels"><span class="type-signature"></span>getLabels<span class="signature">(name<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Array.&lt;<a href="Attribute.html">Attribute</a>>}</span></h4>
@ -2576,7 +2576,7 @@
</dt> </dt>
<dd> <dd>
<span class="param-type">Promise.&lt;Array.&lt;<a href="Attribute.html">Attribute</a>>></span> <span class="param-type">Array.&lt;<a href="Attribute.html">Attribute</a>></span>
</dd> </dd>
@ -2594,7 +2594,7 @@
<h4 class="name" id="getLabelValue"><span class="type-signature">(async) </span>getLabelValue<span class="signature">(name)</span><span class="type-signature"> &rarr; {Promise.&lt;string>}</span></h4> <h4 class="name" id="getLabelValue"><span class="type-signature"></span>getLabelValue<span class="signature">(name)</span><span class="type-signature"> &rarr; {string}</span></h4>
@ -2731,7 +2731,7 @@
</dt> </dt>
<dd> <dd>
<span class="param-type">Promise.&lt;string></span> <span class="param-type">string</span>
</dd> </dd>
@ -4361,7 +4361,7 @@
<h4 class="name" id="getParentNotes"><span class="type-signature">(async) </span>getParentNotes<span class="signature">()</span><span class="type-signature"> &rarr; {Promise.&lt;Array.&lt;<a href="NoteShort.html">NoteShort</a>>>}</span></h4> <h4 class="name" id="getParentNotes"><span class="type-signature"></span>getParentNotes<span class="signature">()</span><span class="type-signature"> &rarr; {Array.&lt;<a href="NoteShort.html">NoteShort</a>>}</span></h4>
@ -4445,7 +4445,7 @@
</dt> </dt>
<dd> <dd>
<span class="param-type">Promise.&lt;Array.&lt;<a href="NoteShort.html">NoteShort</a>>></span> <span class="param-type">Array.&lt;<a href="NoteShort.html">NoteShort</a>></span>
</dd> </dd>
@ -4463,7 +4463,7 @@
<h4 class="name" id="getRelation"><span class="type-signature">(async) </span>getRelation<span class="signature">(name)</span><span class="type-signature"> &rarr; {Promise.&lt;<a href="Attribute.html">Attribute</a>>}</span></h4> <h4 class="name" id="getRelation"><span class="type-signature"></span>getRelation<span class="signature">(name)</span><span class="type-signature"> &rarr; {<a href="Attribute.html">Attribute</a>}</span></h4>
@ -4600,7 +4600,7 @@
</dt> </dt>
<dd> <dd>
<span class="param-type">Promise.&lt;<a href="Attribute.html">Attribute</a>></span> <span class="param-type"><a href="Attribute.html">Attribute</a></span>
</dd> </dd>
@ -4618,7 +4618,7 @@
<h4 class="name" id="getRelationDefinitions"><span class="type-signature">(async) </span>getRelationDefinitions<span class="signature">(name<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Promise.&lt;Array.&lt;<a href="Attribute.html">Attribute</a>>>}</span></h4> <h4 class="name" id="getRelationDefinitions"><span class="type-signature"></span>getRelationDefinitions<span class="signature">(name<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Array.&lt;<a href="Attribute.html">Attribute</a>>}</span></h4>
@ -4767,7 +4767,7 @@
</dt> </dt>
<dd> <dd>
<span class="param-type">Promise.&lt;Array.&lt;<a href="Attribute.html">Attribute</a>>></span> <span class="param-type">Array.&lt;<a href="Attribute.html">Attribute</a>></span>
</dd> </dd>
@ -4785,7 +4785,7 @@
<h4 class="name" id="getRelations"><span class="type-signature">(async) </span>getRelations<span class="signature">(name<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Promise.&lt;Array.&lt;<a href="Attribute.html">Attribute</a>>>}</span></h4> <h4 class="name" id="getRelations"><span class="type-signature"></span>getRelations<span class="signature">(name<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Array.&lt;<a href="Attribute.html">Attribute</a>>}</span></h4>
@ -4934,7 +4934,7 @@
</dt> </dt>
<dd> <dd>
<span class="param-type">Promise.&lt;Array.&lt;<a href="Attribute.html">Attribute</a>>></span> <span class="param-type">Array.&lt;<a href="Attribute.html">Attribute</a>></span>
</dd> </dd>
@ -5273,7 +5273,7 @@
<h4 class="name" id="getRelationValue"><span class="type-signature">(async) </span>getRelationValue<span class="signature">(name)</span><span class="type-signature"> &rarr; {Promise.&lt;string>}</span></h4> <h4 class="name" id="getRelationValue"><span class="type-signature"></span>getRelationValue<span class="signature">(name)</span><span class="type-signature"> &rarr; {string}</span></h4>
@ -5410,7 +5410,7 @@
</dt> </dt>
<dd> <dd>
<span class="param-type">Promise.&lt;string></span> <span class="param-type">string</span>
</dd> </dd>
@ -5534,7 +5534,7 @@
<h4 class="name" id="hasAttribute"><span class="type-signature">(async) </span>hasAttribute<span class="signature">(type, name)</span><span class="type-signature"> &rarr; {Promise.&lt;boolean>}</span></h4> <h4 class="name" id="hasAttribute"><span class="type-signature"></span>hasAttribute<span class="signature">(type, name)</span><span class="type-signature"> &rarr; {boolean}</span></h4>
@ -5694,7 +5694,7 @@
</dt> </dt>
<dd> <dd>
<span class="param-type">Promise.&lt;boolean></span> <span class="param-type">boolean</span>
</dd> </dd>
@ -5814,7 +5814,7 @@
<h4 class="name" id="hasLabel"><span class="type-signature">(async) </span>hasLabel<span class="signature">(name)</span><span class="type-signature"> &rarr; {Promise.&lt;boolean>}</span></h4> <h4 class="name" id="hasLabel"><span class="type-signature"></span>hasLabel<span class="signature">(name)</span><span class="type-signature"> &rarr; {boolean}</span></h4>
@ -5951,7 +5951,7 @@
</dt> </dt>
<dd> <dd>
<span class="param-type">Promise.&lt;boolean></span> <span class="param-type">boolean</span>
</dd> </dd>
@ -6457,7 +6457,7 @@
<h4 class="name" id="hasRelation"><span class="type-signature">(async) </span>hasRelation<span class="signature">(name)</span><span class="type-signature"> &rarr; {Promise.&lt;boolean>}</span></h4> <h4 class="name" id="hasRelation"><span class="type-signature"></span>hasRelation<span class="signature">(name)</span><span class="type-signature"> &rarr; {boolean}</span></h4>
@ -6594,7 +6594,7 @@
</dt> </dt>
<dd> <dd>
<span class="param-type">Promise.&lt;boolean></span> <span class="param-type">boolean</span>
</dd> </dd>

View File

@ -136,8 +136,8 @@ class NoteShort {
return Object.values(this.parentToBranch); return Object.values(this.parentToBranch);
} }
/** @returns {Promise&lt;Branch[]>} */ /** @returns {Branch[]} */
async getBranches() { getBranches() {
const branchIds = Object.values(this.parentToBranch); const branchIds = Object.values(this.parentToBranch);
return this.treeCache.getBranches(branchIds); return this.treeCache.getBranches(branchIds);
@ -148,8 +148,8 @@ class NoteShort {
return this.children.length > 0; return this.children.length > 0;
} }
/** @returns {Promise&lt;Branch[]>} */ /** @returns {Branch[]} */
async getChildBranches() { getChildBranches() {
// don't use Object.values() to guarantee order // don't use Object.values() to guarantee order
const branchIds = this.children.map(childNoteId => this.childToBranch[childNoteId]); const branchIds = this.children.map(childNoteId => this.childToBranch[childNoteId]);
@ -161,9 +161,9 @@ class NoteShort {
return this.parents; return this.parents;
} }
/** @returns {Promise&lt;NoteShort[]>} */ /** @returns {NoteShort[]} */
async getParentNotes() { getParentNotes() {
return await this.treeCache.getNotes(this.parents); return this.treeCache.getNotesFromCache(this.parents);
} }
/** @returns {string[]} */ /** @returns {string[]} */
@ -192,9 +192,9 @@ class NoteShort {
/** /**
* @param {string} [type] - (optional) attribute type to filter * @param {string} [type] - (optional) attribute type to filter
* @param {string} [name] - (optional) attribute name to filter * @param {string} [name] - (optional) attribute name to filter
* @returns {Promise&lt;Attribute[]>} all note's attributes, including inherited ones * @returns {Attribute[]} all note's attributes, including inherited ones
*/ */
async getAttributes(type, name) { getAttributes(type, name) {
const ownedAttributes = this.getOwnedAttributes(); const ownedAttributes = this.getOwnedAttributes();
const attrArrs = [ const attrArrs = [
@ -202,16 +202,16 @@ class NoteShort {
]; ];
for (const templateAttr of ownedAttributes.filter(oa => oa.type === 'relation' &amp;&amp; oa.name === 'template')) { for (const templateAttr of ownedAttributes.filter(oa => oa.type === 'relation' &amp;&amp; oa.name === 'template')) {
const templateNote = await this.treeCache.getNote(templateAttr.value); const templateNote = this.treeCache.getNoteFromCache(templateAttr.value);
if (templateNote) { if (templateNote) {
attrArrs.push(await templateNote.getAttributes()); attrArrs.push(templateNote.getAttributes());
} }
} }
if (this.noteId !== 'root') { if (this.noteId !== 'root') {
for (const parentNote of await this.getParentNotes()) { for (const parentNote of this.getParentNotes()) {
attrArrs.push(await parentNote.getInheritableAttributes()); attrArrs.push(parentNote.getInheritableAttributes());
} }
} }
@ -232,8 +232,8 @@ class NoteShort {
} }
} }
async getInheritableAttributes() { getInheritableAttributes() {
const attrs = await this.getAttributes(); const attrs = this.getAttributes();
return attrs.filter(attr => attr.isInheritable); return attrs.filter(attr => attr.isInheritable);
} }
@ -248,18 +248,18 @@ class NoteShort {
/** /**
* @param {string} [name] - label name to filter * @param {string} [name] - label name to filter
* @returns {Promise&lt;Attribute[]>} all note's labels (attributes with type label), including inherited ones * @returns {Attribute[]} all note's labels (attributes with type label), including inherited ones
*/ */
async getLabels(name) { getLabels(name) {
return await this.getAttributes(LABEL, name); return this.getAttributes(LABEL, name);
} }
/** /**
* @param {string} [name] - label name to filter * @param {string} [name] - label name to filter
* @returns {Promise&lt;Attribute[]>} all note's label definitions, including inherited ones * @returns {Attribute[]} all note's label definitions, including inherited ones
*/ */
async getLabelDefinitions(name) { getLabelDefinitions(name) {
return await this.getAttributes(LABEL_DEFINITION, name); return this.getAttributes(LABEL_DEFINITION, name);
} }
/** /**
@ -272,27 +272,27 @@ class NoteShort {
/** /**
* @param {string} [name] - relation name to filter * @param {string} [name] - relation name to filter
* @returns {Promise&lt;Attribute[]>} all note's relations (attributes with type relation), including inherited ones * @returns {Attribute[]} all note's relations (attributes with type relation), including inherited ones
*/ */
async getRelations(name) { getRelations(name) {
return await this.getAttributes(RELATION, name); return this.getAttributes(RELATION, name);
} }
/** /**
* @param {string} [name] - relation name to filter * @param {string} [name] - relation name to filter
* @returns {Promise&lt;Attribute[]>} all note's relation definitions including inherited ones * @returns {Attribute[]} all note's relation definitions including inherited ones
*/ */
async getRelationDefinitions(name) { getRelationDefinitions(name) {
return await this.getAttributes(RELATION_DEFINITION, name); return this.getAttributes(RELATION_DEFINITION, name);
} }
/** /**
* @param {string} type - attribute type (label, relation, etc.) * @param {string} type - attribute type (label, relation, etc.)
* @param {string} name - attribute name * @param {string} name - attribute name
* @returns {Promise&lt;boolean>} true if note has an attribute with given type and name (including inherited) * @returns {boolean} true if note has an attribute with given type and name (including inherited)
*/ */
async hasAttribute(type, name) { hasAttribute(type, name) {
return !!await this.getAttribute(type, name); return !!this.getAttribute(type, name);
} }
/** /**
@ -318,10 +318,10 @@ class NoteShort {
/** /**
* @param {string} type - attribute type (label, relation, etc.) * @param {string} type - attribute type (label, relation, etc.)
* @param {string} name - attribute name * @param {string} name - attribute name
* @returns {Promise&lt;Attribute>} attribute of given type and name. If there's more such attributes, first is returned. Returns null if there's no such attribute belonging to this note. * @returns {Attribute} attribute of given type and name. If there's more such attributes, first is returned. Returns null if there's no such attribute belonging to this note.
*/ */
async getAttribute(type, name) { getAttribute(type, name) {
const attributes = await this.getAttributes(type, name); const attributes = this.getAttributes(type, name);
return attributes.length > 0 ? attributes[0] : 0; return attributes.length > 0 ? attributes[0] : 0;
} }
@ -340,10 +340,10 @@ class NoteShort {
/** /**
* @param {string} type - attribute type (label, relation, etc.) * @param {string} type - attribute type (label, relation, etc.)
* @param {string} name - attribute name * @param {string} name - attribute name
* @returns {Promise&lt;string>} attribute value of given type and name or null if no such attribute exists. * @returns {string} attribute value of given type and name or null if no such attribute exists.
*/ */
async getAttributeValue(type, name) { getAttributeValue(type, name) {
const attr = await this.getAttribute(type, name); const attr = this.getAttribute(type, name);
return attr ? attr.value : null; return attr ? attr.value : null;
} }
@ -356,9 +356,9 @@ class NoteShort {
/** /**
* @param {string} name - label name * @param {string} name - label name
* @returns {Promise&lt;boolean>} true if label exists (including inherited) * @returns {boolean} true if label exists (including inherited)
*/ */
async hasLabel(name) { return await this.hasAttribute(LABEL, name); } hasLabel(name) { return this.hasAttribute(LABEL, name); }
/** /**
* @param {string} name - relation name * @param {string} name - relation name
@ -368,9 +368,9 @@ class NoteShort {
/** /**
* @param {string} name - relation name * @param {string} name - relation name
* @returns {Promise&lt;boolean>} true if relation exists (including inherited) * @returns {boolean} true if relation exists (including inherited)
*/ */
async hasRelation(name) { return await this.hasAttribute(RELATION, name); } hasRelation(name) { return this.hasAttribute(RELATION, name); }
/** /**
* @param {string} name - label name * @param {string} name - label name
@ -380,9 +380,9 @@ class NoteShort {
/** /**
* @param {string} name - label name * @param {string} name - label name
* @returns {Promise&lt;Attribute>} label if it exists, null otherwise * @returns {Attribute} label if it exists, null otherwise
*/ */
async getLabel(name) { return await this.getAttribute(LABEL, name); } getLabel(name) { return this.getAttribute(LABEL, name); }
/** /**
* @param {string} name - relation name * @param {string} name - relation name
@ -392,9 +392,9 @@ class NoteShort {
/** /**
* @param {string} name - relation name * @param {string} name - relation name
* @returns {Promise&lt;Attribute>} relation if it exists, null otherwise * @returns {Attribute} relation if it exists, null otherwise
*/ */
async getRelation(name) { return await this.getAttribute(RELATION, name); } getRelation(name) { return this.getAttribute(RELATION, name); }
/** /**
* @param {string} name - label name * @param {string} name - label name
@ -404,9 +404,9 @@ class NoteShort {
/** /**
* @param {string} name - label name * @param {string} name - label name
* @returns {Promise&lt;string>} label value if label exists, null otherwise * @returns {string} label value if label exists, null otherwise
*/ */
async getLabelValue(name) { return await this.getAttributeValue(LABEL, name); } getLabelValue(name) { return this.getAttributeValue(LABEL, name); }
/** /**
* @param {string} name - relation name * @param {string} name - relation name
@ -416,9 +416,9 @@ class NoteShort {
/** /**
* @param {string} name - relation name * @param {string} name - relation name
* @returns {Promise&lt;string>} relation value if relation exists, null otherwise * @returns {string} relation value if relation exists, null otherwise
*/ */
async getRelationValue(name) { return await this.getAttributeValue(RELATION, name); } getRelationValue(name) { return this.getAttributeValue(RELATION, name); }
/** /**
* @param {string} name * @param {string} name
@ -435,7 +435,7 @@ class NoteShort {
* @returns {Promise&lt;NoteShort[]>} * @returns {Promise&lt;NoteShort[]>}
*/ */
async getRelationTargets(name) { async getRelationTargets(name) {
const relations = await this.getRelations(name); const relations = this.getRelations(name);
const targets = []; const targets = [];
for (const relation of relations) { for (const relation of relations) {
@ -474,8 +474,8 @@ class NoteShort {
return dto; return dto;
} }
async getCssClass() { getCssClass() {
const labels = await this.getLabels('cssClass'); const labels = this.getLabels('cssClass');
return labels.map(l => l.value).join(' '); return labels.map(l => l.value).join(' ');
} }
} }

View File

@ -86,7 +86,7 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain
await ws.waitForMaxKnownSyncId(); await ws.waitForMaxKnownSyncId();
await appContext.tabManager.getActiveTabContext().setNote(notePath); await appContext.tabManager.getActiveTabContext().setNote(notePath);
appContext.triggerCommand('focusAndSelectTitle'); appContext.triggerEvent('focusAndSelectTitle');
}; };
/** /**
@ -310,7 +310,7 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain
* @method * @method
* @returns {NoteShort} active note (loaded into right pane) * @returns {NoteShort} active note (loaded into right pane)
*/ */
this.getActiveTabNote = appContext.tabManager.getActiveTabNote; this.getActiveTabNote = () => appContext.tabManager.getActiveTabNote();
/** /**
* See https://ckeditor.com/docs/ckeditor5/latest/api/module_core_editor_editor-Editor.html for a documentation on the returned instance. * See https://ckeditor.com/docs/ckeditor5/latest/api/module_core_editor_editor-Editor.html for a documentation on the returned instance.
@ -324,7 +324,7 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain
* @method * @method
* @returns {Promise&lt;string|null>} returns note path of active note or null if there isn't active note * @returns {Promise&lt;string|null>} returns note path of active note or null if there isn't active note
*/ */
this.getActiveTabNotePath = appContext.tabManager.getActiveTabNotePath; this.getActiveTabNotePath = () => appContext.tabManager.getActiveTabNotePath();
/** /**
* @method * @method

View File

@ -203,6 +203,25 @@ subscribeToMessages(message => {
}); });
async function processSyncRows(syncRows) { 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); const loadResults = new LoadResults(treeCache);
syncRows.filter(sync => sync.entityName === 'notes').forEach(sync => { syncRows.filter(sync => sync.entityName === 'notes').forEach(sync => {