mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 09:58:32 +02:00
renamed treeCache into froca
This commit is contained in:
parent
4311834d75
commit
af5b1021c7
@ -411,7 +411,7 @@ class Note extends Entity {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: this code is quite questionable, one problem is that other caches (TreeCache, NoteCache) have nothing like that
|
// FIXME: this code is quite questionable, one problem is that other caches (Froca, NoteCache) have nothing like that
|
||||||
if (attr.isDefinition()) {
|
if (attr.isDefinition()) {
|
||||||
const firstDefinitionIndex = attributes.findIndex(el => el.type === attr.type && el.name === attr.name);
|
const firstDefinitionIndex = attributes.findIndex(el => el.type === attr.type && el.name === attr.name);
|
||||||
|
|
||||||
|
@ -28,11 +28,11 @@
|
|||||||
|
|
||||||
<header>
|
<header>
|
||||||
|
|
||||||
<h2><span class="attribs"><span class="type-signature"></span></span>NoteShort<span class="signature">(treeCache, row)</span><span class="type-signature"></span></h2>
|
<h2><span class="attribs"><span class="type-signature"></span></span>NoteShort<span class="signature">(froca, row)</span><span class="type-signature"></span></h2>
|
||||||
|
|
||||||
<div class="class-description">FIXME: since there's no "full note" anymore we can rename this to Note
|
<div class="class-description">FIXME: since there's no "full note" anymore we can rename this to Note
|
||||||
|
|
||||||
This note's representation is used in note tree and is kept in TreeCache.</div>
|
This note's representation is used in note tree and is kept in Froca.</div>
|
||||||
|
|
||||||
|
|
||||||
</header>
|
</header>
|
||||||
@ -47,7 +47,7 @@ This note's representation is used in note tree and is kept in TreeCache.</div>
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
<h4 class="name" id="NoteShort"><span class="type-signature"></span>new NoteShort<span class="signature">(treeCache, row)</span><span class="type-signature"></span></h4>
|
<h4 class="name" id="NoteShort"><span class="type-signature"></span>new NoteShort<span class="signature">(froca, row)</span><span class="type-signature"></span></h4>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -87,13 +87,13 @@ This note's representation is used in note tree and is kept in TreeCache.</div>
|
|||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
|
|
||||||
<td class="name"><code>treeCache</code></td>
|
<td class="name"><code>froca</code></td>
|
||||||
|
|
||||||
|
|
||||||
<td class="type">
|
<td class="type">
|
||||||
|
|
||||||
|
|
||||||
<span class="param-type">TreeCache</span>
|
<span class="param-type">Froca</span>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -28,8 +28,8 @@
|
|||||||
<article>
|
<article>
|
||||||
<pre class="prettyprint source linenums"><code>/** Represents mapping between note and parent note */
|
<pre class="prettyprint source linenums"><code>/** Represents mapping between note and parent note */
|
||||||
class Branch {
|
class Branch {
|
||||||
constructor(treeCache, row) {
|
constructor(froca, row) {
|
||||||
this.treeCache = treeCache;
|
this.froca = froca;
|
||||||
/** @param {string} primary key */
|
/** @param {string} primary key */
|
||||||
this.branchId = row.branchId;
|
this.branchId = row.branchId;
|
||||||
/** @param {string} */
|
/** @param {string} */
|
||||||
@ -47,7 +47,7 @@ class Branch {
|
|||||||
|
|
||||||
/** @returns {NoteShort} */
|
/** @returns {NoteShort} */
|
||||||
async getNote() {
|
async getNote() {
|
||||||
return await this.treeCache.getNote(this.noteId);
|
return await this.froca.getNote(this.noteId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @returns {boolean} true if it's top level, meaning its parent is root note */
|
/** @returns {boolean} true if it's top level, meaning its parent is root note */
|
||||||
|
@ -29,8 +29,8 @@
|
|||||||
<pre class="prettyprint source linenums"><code>import promotedAttributeDefinitionParser from '../services/promoted_attribute_definition_parser.js';
|
<pre class="prettyprint source linenums"><code>import promotedAttributeDefinitionParser from '../services/promoted_attribute_definition_parser.js';
|
||||||
|
|
||||||
class Attribute {
|
class Attribute {
|
||||||
constructor(treeCache, row) {
|
constructor(froca, row) {
|
||||||
this.treeCache = treeCache;
|
this.froca = froca;
|
||||||
|
|
||||||
this.update(row);
|
this.update(row);
|
||||||
}
|
}
|
||||||
@ -56,7 +56,7 @@ class Attribute {
|
|||||||
|
|
||||||
/** @returns {NoteShort} */
|
/** @returns {NoteShort} */
|
||||||
getNote() {
|
getNote() {
|
||||||
return this.treeCache.notes[this.noteId];
|
return this.froca.notes[this.noteId];
|
||||||
}
|
}
|
||||||
|
|
||||||
get targetNoteId() { // alias
|
get targetNoteId() { // alias
|
||||||
@ -123,7 +123,7 @@ class Attribute {
|
|||||||
|
|
||||||
get dto() {
|
get dto() {
|
||||||
const dto = Object.assign({}, this);
|
const dto = Object.assign({}, this);
|
||||||
delete dto.treeCache;
|
delete dto.froca;
|
||||||
|
|
||||||
return dto;
|
return dto;
|
||||||
}
|
}
|
||||||
|
@ -28,8 +28,8 @@
|
|||||||
<article>
|
<article>
|
||||||
<pre class="prettyprint source linenums"><code>/** Represents mapping between note and parent note */
|
<pre class="prettyprint source linenums"><code>/** Represents mapping between note and parent note */
|
||||||
class Branch {
|
class Branch {
|
||||||
constructor(treeCache, row) {
|
constructor(froca, row) {
|
||||||
this.treeCache = treeCache;
|
this.froca = froca;
|
||||||
|
|
||||||
this.update(row);
|
this.update(row);
|
||||||
}
|
}
|
||||||
@ -55,17 +55,17 @@ class Branch {
|
|||||||
|
|
||||||
/** @returns {NoteShort} */
|
/** @returns {NoteShort} */
|
||||||
async getNote() {
|
async getNote() {
|
||||||
return this.treeCache.getNote(this.noteId);
|
return this.froca.getNote(this.noteId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @returns {NoteShort} */
|
/** @returns {NoteShort} */
|
||||||
getNoteFromCache() {
|
getNoteFromCache() {
|
||||||
return this.treeCache.getNoteFromCache(this.noteId);
|
return this.froca.getNoteFromCache(this.noteId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @returns {NoteShort} */
|
/** @returns {NoteShort} */
|
||||||
async getParentNote() {
|
async getParentNote() {
|
||||||
return this.treeCache.getNote(this.parentNoteId);
|
return this.froca.getNote(this.parentNoteId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @returns {boolean} true if it's top level, meaning its parent is root note */
|
/** @returns {boolean} true if it's top level, meaning its parent is root note */
|
||||||
|
@ -32,8 +32,8 @@
|
|||||||
* Represents full note, specifically including note's content.
|
* Represents full note, specifically including note's content.
|
||||||
*/
|
*/
|
||||||
class NoteFull extends NoteShort {
|
class NoteFull extends NoteShort {
|
||||||
constructor(treeCache, row, noteShort) {
|
constructor(froca, row, noteShort) {
|
||||||
super(treeCache, row, []);
|
super(froca, row, []);
|
||||||
|
|
||||||
/** @param {string} */
|
/** @param {string} */
|
||||||
this.content = row.content;
|
this.content = row.content;
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
import noteAttributeCache from "../services/note_attribute_cache.js";
|
import noteAttributeCache from "../services/note_attribute_cache.js";
|
||||||
import ws from "../services/ws.js";
|
import ws from "../services/ws.js";
|
||||||
import options from "../services/options.js";
|
import options from "../services/options.js";
|
||||||
import treeCache from "../services/tree_cache.js";
|
import froca from "../services/tree_cache.js";
|
||||||
|
|
||||||
const LABEL = 'label';
|
const LABEL = 'label';
|
||||||
const RELATION = 'relation';
|
const RELATION = 'relation';
|
||||||
@ -48,15 +48,15 @@ const NOTE_TYPE_ICONS = {
|
|||||||
/**
|
/**
|
||||||
* FIXME: since there's no "full note" anymore we can rename this to Note
|
* FIXME: since there's no "full note" anymore we can rename this to Note
|
||||||
*
|
*
|
||||||
* This note's representation is used in note tree and is kept in TreeCache.
|
* This note's representation is used in note tree and is kept in Froca.
|
||||||
*/
|
*/
|
||||||
class NoteShort {
|
class NoteShort {
|
||||||
/**
|
/**
|
||||||
* @param {TreeCache} treeCache
|
* @param {Froca} froca
|
||||||
* @param {Object.<string, Object>} row
|
* @param {Object.<string, Object>} row
|
||||||
*/
|
*/
|
||||||
constructor(treeCache, row) {
|
constructor(froca, row) {
|
||||||
this.treeCache = treeCache;
|
this.froca = froca;
|
||||||
|
|
||||||
/** @type {string[]} */
|
/** @type {string[]} */
|
||||||
this.attributes = [];
|
this.attributes = [];
|
||||||
@ -121,7 +121,7 @@ class NoteShort {
|
|||||||
const branchIdPos = {};
|
const branchIdPos = {};
|
||||||
|
|
||||||
for (const branchId of Object.values(this.childToBranch)) {
|
for (const branchId of Object.values(this.childToBranch)) {
|
||||||
branchIdPos[branchId] = this.treeCache.getBranch(branchId).notePosition;
|
branchIdPos[branchId] = this.froca.getBranch(branchId).notePosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.children.sort((a, b) => branchIdPos[this.childToBranch[a]] < branchIdPos[this.childToBranch[b]] ? -1 : 1);
|
this.children.sort((a, b) => branchIdPos[this.childToBranch[a]] < branchIdPos[this.childToBranch[b]] ? -1 : 1);
|
||||||
@ -133,7 +133,7 @@ class NoteShort {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getContent() {
|
async getContent() {
|
||||||
// we're not caching content since these objects are in treeCache and as such pretty long lived
|
// we're not caching content since these objects are in froca and as such pretty long lived
|
||||||
const note = await server.get("notes/" + this.noteId);
|
const note = await server.get("notes/" + this.noteId);
|
||||||
|
|
||||||
return note.content;
|
return note.content;
|
||||||
@ -161,7 +161,7 @@ class NoteShort {
|
|||||||
getBranches() {
|
getBranches() {
|
||||||
const branchIds = Object.values(this.parentToBranch);
|
const branchIds = Object.values(this.parentToBranch);
|
||||||
|
|
||||||
return this.treeCache.getBranches(branchIds);
|
return this.froca.getBranches(branchIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @returns {boolean} */
|
/** @returns {boolean} */
|
||||||
@ -174,7 +174,7 @@ class NoteShort {
|
|||||||
// 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]);
|
||||||
|
|
||||||
return this.treeCache.getBranches(branchIds);
|
return this.froca.getBranches(branchIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @returns {string[]} */
|
/** @returns {string[]} */
|
||||||
@ -184,7 +184,7 @@ class NoteShort {
|
|||||||
|
|
||||||
/** @returns {NoteShort[]} */
|
/** @returns {NoteShort[]} */
|
||||||
getParentNotes() {
|
getParentNotes() {
|
||||||
return this.treeCache.getNotesFromCache(this.parents);
|
return this.froca.getNotesFromCache(this.parents);
|
||||||
}
|
}
|
||||||
|
|
||||||
// will sort the parents so that non-search & non-archived are first and archived at the end
|
// will sort the parents so that non-search & non-archived are first and archived at the end
|
||||||
@ -197,7 +197,7 @@ class NoteShort {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
const aNote = this.treeCache.getNoteFromCache([aNoteId]);
|
const aNote = this.froca.getNoteFromCache([aNoteId]);
|
||||||
|
|
||||||
if (aNote.hasLabel('archived')) {
|
if (aNote.hasLabel('archived')) {
|
||||||
return 1;
|
return 1;
|
||||||
@ -214,7 +214,7 @@ class NoteShort {
|
|||||||
|
|
||||||
/** @returns {Promise<NoteShort[]>} */
|
/** @returns {Promise<NoteShort[]>} */
|
||||||
async getChildNotes() {
|
async getChildNotes() {
|
||||||
return await this.treeCache.getNotes(this.children);
|
return await this.froca.getNotes(this.children);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -224,7 +224,7 @@ class NoteShort {
|
|||||||
*/
|
*/
|
||||||
getOwnedAttributes(type, name) {
|
getOwnedAttributes(type, name) {
|
||||||
const attrs = this.attributes
|
const attrs = this.attributes
|
||||||
.map(attributeId => this.treeCache.attributes[attributeId])
|
.map(attributeId => this.froca.attributes[attributeId])
|
||||||
.filter(Boolean); // filter out nulls;
|
.filter(Boolean); // filter out nulls;
|
||||||
|
|
||||||
return this.__filterAttrs(attrs, type, name);
|
return this.__filterAttrs(attrs, type, name);
|
||||||
@ -260,7 +260,7 @@ class NoteShort {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (const templateAttr of attrArrs.flat().filter(attr => attr.type === 'relation' && attr.name === 'template')) {
|
for (const templateAttr of attrArrs.flat().filter(attr => attr.type === 'relation' && attr.name === 'template')) {
|
||||||
const templateNote = this.treeCache.notes[templateAttr.value];
|
const templateNote = this.froca.notes[templateAttr.value];
|
||||||
|
|
||||||
if (templateNote && templateNote.noteId !== this.noteId) {
|
if (templateNote && templateNote.noteId !== this.noteId) {
|
||||||
attrArrs.push(templateNote.__getCachedAttributes(newPath));
|
attrArrs.push(templateNote.__getCachedAttributes(newPath));
|
||||||
@ -329,8 +329,8 @@ class NoteShort {
|
|||||||
const notePaths = this.getAllNotePaths().map(path => ({
|
const notePaths = this.getAllNotePaths().map(path => ({
|
||||||
notePath: path,
|
notePath: path,
|
||||||
isInHoistedSubTree: path.includes(hoistedNotePath),
|
isInHoistedSubTree: path.includes(hoistedNotePath),
|
||||||
isArchived: path.find(noteId => treeCache.notes[noteId].hasLabel('archived')),
|
isArchived: path.find(noteId => froca.notes[noteId].hasLabel('archived')),
|
||||||
isSearch: path.find(noteId => treeCache.notes[noteId].type === 'search')
|
isSearch: path.find(noteId => froca.notes[noteId].type === 'search')
|
||||||
}));
|
}));
|
||||||
|
|
||||||
notePaths.sort((a, b) => {
|
notePaths.sort((a, b) => {
|
||||||
@ -608,7 +608,7 @@ class NoteShort {
|
|||||||
const targets = [];
|
const targets = [];
|
||||||
|
|
||||||
for (const relation of relations) {
|
for (const relation of relations) {
|
||||||
targets.push(await this.treeCache.getNote(relation.value));
|
targets.push(await this.froca.getNote(relation.value));
|
||||||
}
|
}
|
||||||
|
|
||||||
return targets;
|
return targets;
|
||||||
@ -620,7 +620,7 @@ class NoteShort {
|
|||||||
getTemplateNotes() {
|
getTemplateNotes() {
|
||||||
const relations = this.getRelations('template');
|
const relations = this.getRelations('template');
|
||||||
|
|
||||||
return relations.map(rel => this.treeCache.notes[rel.value]);
|
return relations.map(rel => this.froca.notes[rel.value]);
|
||||||
}
|
}
|
||||||
|
|
||||||
getPromotedDefinitionAttributes() {
|
getPromotedDefinitionAttributes() {
|
||||||
@ -681,7 +681,7 @@ class NoteShort {
|
|||||||
*/
|
*/
|
||||||
getTargetRelations() {
|
getTargetRelations() {
|
||||||
return this.targetRelations
|
return this.targetRelations
|
||||||
.map(attributeId => this.treeCache.attributes[attributeId]);
|
.map(attributeId => this.froca.attributes[attributeId]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -692,7 +692,7 @@ class NoteShort {
|
|||||||
async getTargetRelationSourceNotes() {
|
async getTargetRelationSourceNotes() {
|
||||||
const targetRelations = this.getTargetRelations();
|
const targetRelations = this.getTargetRelations();
|
||||||
|
|
||||||
return await this.treeCache.getNotes(targetRelations.map(tr => tr.noteId));
|
return await this.froca.getNotes(targetRelations.map(tr => tr.noteId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -701,7 +701,7 @@ class NoteShort {
|
|||||||
* @return {Promise<NoteComplement>}
|
* @return {Promise<NoteComplement>}
|
||||||
*/
|
*/
|
||||||
async getNoteComplement() {
|
async getNoteComplement() {
|
||||||
return await this.treeCache.getNoteComplement(this.noteId);
|
return await this.froca.getNoteComplement(this.noteId);
|
||||||
}
|
}
|
||||||
|
|
||||||
get toString() {
|
get toString() {
|
||||||
@ -710,7 +710,7 @@ class NoteShort {
|
|||||||
|
|
||||||
get dto() {
|
get dto() {
|
||||||
const dto = Object.assign({}, this);
|
const dto = Object.assign({}, this);
|
||||||
delete dto.treeCache;
|
delete dto.froca;
|
||||||
|
|
||||||
return dto;
|
return dto;
|
||||||
}
|
}
|
||||||
|
@ -32,8 +32,8 @@
|
|||||||
* Represents full note, specifically including note's content.
|
* Represents full note, specifically including note's content.
|
||||||
*/
|
*/
|
||||||
class NoteFull extends NoteShort {
|
class NoteFull extends NoteShort {
|
||||||
constructor(treeCache, row) {
|
constructor(froca, row) {
|
||||||
super(treeCache, row);
|
super(froca, row);
|
||||||
|
|
||||||
/** @param {string} */
|
/** @param {string} */
|
||||||
this.content = row.content;
|
this.content = row.content;
|
||||||
|
@ -27,12 +27,12 @@
|
|||||||
<section>
|
<section>
|
||||||
<article>
|
<article>
|
||||||
<pre class="prettyprint source linenums"><code>/**
|
<pre class="prettyprint source linenums"><code>/**
|
||||||
* This note's representation is used in note tree and is kept in TreeCache.
|
* This note's representation is used in note tree and is kept in Froca.
|
||||||
* Its notable omission is the note content.
|
* Its notable omission is the note content.
|
||||||
*/
|
*/
|
||||||
class NoteShort {
|
class NoteShort {
|
||||||
constructor(treeCache, row) {
|
constructor(froca, row) {
|
||||||
this.treeCache = treeCache;
|
this.froca = froca;
|
||||||
/** @param {string} */
|
/** @param {string} */
|
||||||
this.noteId = row.noteId;
|
this.noteId = row.noteId;
|
||||||
/** @param {string} */
|
/** @param {string} */
|
||||||
@ -55,48 +55,48 @@ class NoteShort {
|
|||||||
|
|
||||||
/** @returns {Promise<Array.<Branch>>} */
|
/** @returns {Promise<Array.<Branch>>} */
|
||||||
async getBranches() {
|
async getBranches() {
|
||||||
const branchIds = this.treeCache.parents[this.noteId].map(
|
const branchIds = this.froca.parents[this.noteId].map(
|
||||||
parentNoteId => this.treeCache.getBranchIdByChildParent(this.noteId, parentNoteId));
|
parentNoteId => this.froca.getBranchIdByChildParent(this.noteId, parentNoteId));
|
||||||
|
|
||||||
return this.treeCache.getBranches(branchIds);
|
return this.froca.getBranches(branchIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @returns {boolean} */
|
/** @returns {boolean} */
|
||||||
hasChildren() {
|
hasChildren() {
|
||||||
return this.treeCache.children[this.noteId]
|
return this.froca.children[this.noteId]
|
||||||
&& this.treeCache.children[this.noteId].length > 0;
|
&& this.froca.children[this.noteId].length > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @returns {Promise<Array.<Branch>>} */
|
/** @returns {Promise<Array.<Branch>>} */
|
||||||
async getChildBranches() {
|
async getChildBranches() {
|
||||||
if (!this.treeCache.children[this.noteId]) {
|
if (!this.froca.children[this.noteId]) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
const branchIds = this.treeCache.children[this.noteId].map(
|
const branchIds = this.froca.children[this.noteId].map(
|
||||||
childNoteId => this.treeCache.getBranchIdByChildParent(childNoteId, this.noteId));
|
childNoteId => this.froca.getBranchIdByChildParent(childNoteId, this.noteId));
|
||||||
|
|
||||||
return await this.treeCache.getBranches(branchIds);
|
return await this.froca.getBranches(branchIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @returns {Array.<string>} */
|
/** @returns {Array.<string>} */
|
||||||
getParentNoteIds() {
|
getParentNoteIds() {
|
||||||
return this.treeCache.parents[this.noteId] || [];
|
return this.froca.parents[this.noteId] || [];
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @returns {Promise<Array.<NoteShort>>} */
|
/** @returns {Promise<Array.<NoteShort>>} */
|
||||||
async getParentNotes() {
|
async getParentNotes() {
|
||||||
return await this.treeCache.getNotes(this.getParentNoteIds());
|
return await this.froca.getNotes(this.getParentNoteIds());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @returns {Array.<string>} */
|
/** @returns {Array.<string>} */
|
||||||
getChildNoteIds() {
|
getChildNoteIds() {
|
||||||
return this.treeCache.children[this.noteId] || [];
|
return this.froca.children[this.noteId] || [];
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @returns {Promise<Array.<NoteShort>>} */
|
/** @returns {Promise<Array.<NoteShort>>} */
|
||||||
async getChildNotes() {
|
async getChildNotes() {
|
||||||
return await this.treeCache.getNotes(this.getChildNoteIds());
|
return await this.froca.getNotes(this.getChildNoteIds());
|
||||||
}
|
}
|
||||||
|
|
||||||
get toString() {
|
get toString() {
|
||||||
@ -105,7 +105,7 @@ class NoteShort {
|
|||||||
|
|
||||||
get dto() {
|
get dto() {
|
||||||
const dto = Object.assign({}, this);
|
const dto = Object.assign({}, this);
|
||||||
delete dto.treeCache;
|
delete dto.froca;
|
||||||
delete dto.archived;
|
delete dto.archived;
|
||||||
|
|
||||||
return dto;
|
return dto;
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
import utils from './utils.js';
|
import utils from './utils.js';
|
||||||
import toastService from './toast.js';
|
import toastService from './toast.js';
|
||||||
import linkService from './link.js';
|
import linkService from './link.js';
|
||||||
import treeCache from './tree_cache.js';
|
import froca from './tree_cache.js';
|
||||||
import noteTooltipService from './note_tooltip.js';
|
import noteTooltipService from './note_tooltip.js';
|
||||||
import protectedSessionService from './protected_session.js';
|
import protectedSessionService from './protected_session.js';
|
||||||
import dateNotesService from './date_notes.js';
|
import dateNotesService from './date_notes.js';
|
||||||
@ -251,7 +251,7 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain
|
|||||||
* @param {string} noteId
|
* @param {string} noteId
|
||||||
* @return {Promise<NoteShort>}
|
* @return {Promise<NoteShort>}
|
||||||
*/
|
*/
|
||||||
this.getNote = async noteId => await treeCache.getNote(noteId);
|
this.getNote = async noteId => await froca.getNote(noteId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns list of notes. If note is missing from cache, it's loaded.
|
* Returns list of notes. If note is missing from cache, it's loaded.
|
||||||
@ -263,7 +263,7 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain
|
|||||||
* @param {boolean} [silentNotFoundError] - don't report error if the note is not found
|
* @param {boolean} [silentNotFoundError] - don't report error if the note is not found
|
||||||
* @return {Promise<NoteShort[]>}
|
* @return {Promise<NoteShort[]>}
|
||||||
*/
|
*/
|
||||||
this.getNotes = async (noteIds, silentNotFoundError = false) => await treeCache.getNotes(noteIds, silentNotFoundError);
|
this.getNotes = async (noteIds, silentNotFoundError = false) => await froca.getNotes(noteIds, silentNotFoundError);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update frontend tree (note) cache from the backend.
|
* Update frontend tree (note) cache from the backend.
|
||||||
@ -271,7 +271,7 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain
|
|||||||
* @param {string[]} noteIds
|
* @param {string[]} noteIds
|
||||||
* @method
|
* @method
|
||||||
*/
|
*/
|
||||||
this.reloadNotes = async noteIds => await treeCache.reloadNotes(noteIds);
|
this.reloadNotes = async noteIds => await froca.reloadNotes(noteIds);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instance name identifies particular Trilium instance. It can be useful for scripts
|
* Instance name identifies particular Trilium instance. It can be useful for scripts
|
||||||
|
@ -399,7 +399,7 @@ class Note extends Entity {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: this code is quite questionable, one problem is that other caches (TreeCache, NoteCache) have nothing like that
|
// FIXME: this code is quite questionable, one problem is that other caches (Froca, NoteCache) have nothing like that
|
||||||
if (attr.isDefinition()) {
|
if (attr.isDefinition()) {
|
||||||
const firstDefinitionIndex = attributes.findIndex(el => el.type === attr.type && el.name === attr.name);
|
const firstDefinitionIndex = attributes.findIndex(el => el.type === attr.type && el.name === attr.name);
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import treeService from '../services/tree.js';
|
import treeService from '../services/tree.js';
|
||||||
import server from '../services/server.js';
|
import server from '../services/server.js';
|
||||||
import treeCache from "../services/tree_cache.js";
|
import froca from "../services/tree_cache.js";
|
||||||
import toastService from "../services/toast.js";
|
import toastService from "../services/toast.js";
|
||||||
import utils from "../services/utils.js";
|
import utils from "../services/utils.js";
|
||||||
|
|
||||||
@ -18,14 +18,14 @@ export async function showDialog(notePath) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
branchId = await treeCache.getBranchId(parentNoteId, noteId);
|
branchId = await froca.getBranchId(parentNoteId, noteId);
|
||||||
const branch = treeCache.getBranch(branchId);
|
const branch = froca.getBranch(branchId);
|
||||||
|
|
||||||
if (!branch || branch.noteId === 'root') {
|
if (!branch || branch.noteId === 'root') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const parentNote = await treeCache.getNote(branch.parentNoteId);
|
const parentNote = await froca.getNote(branch.parentNoteId);
|
||||||
|
|
||||||
if (parentNote.type === 'search') {
|
if (parentNote.type === 'search') {
|
||||||
return;
|
return;
|
||||||
|
@ -2,7 +2,7 @@ import noteAutocompleteService from "../services/note_autocomplete.js";
|
|||||||
import utils from "../services/utils.js";
|
import utils from "../services/utils.js";
|
||||||
import treeService from "../services/tree.js";
|
import treeService from "../services/tree.js";
|
||||||
import toastService from "../services/toast.js";
|
import toastService from "../services/toast.js";
|
||||||
import treeCache from "../services/tree_cache.js";
|
import froca from "../services/tree_cache.js";
|
||||||
import branchService from "../services/branches.js";
|
import branchService from "../services/branches.js";
|
||||||
|
|
||||||
const $dialog = $("#clone-to-dialog");
|
const $dialog = $("#clone-to-dialog");
|
||||||
@ -29,7 +29,7 @@ export async function showDialog(noteIds) {
|
|||||||
$noteList.empty();
|
$noteList.empty();
|
||||||
|
|
||||||
for (const noteId of clonedNoteIds) {
|
for (const noteId of clonedNoteIds) {
|
||||||
const note = await treeCache.getNote(noteId);
|
const note = await froca.getNote(noteId);
|
||||||
|
|
||||||
$noteList.append($("<li>").text(note.title));
|
$noteList.append($("<li>").text(note.title));
|
||||||
}
|
}
|
||||||
@ -40,13 +40,13 @@ export async function showDialog(noteIds) {
|
|||||||
|
|
||||||
async function cloneNotesTo(notePath) {
|
async function cloneNotesTo(notePath) {
|
||||||
const {noteId, parentNoteId} = treeService.getNoteIdAndParentIdFromNotePath(notePath);
|
const {noteId, parentNoteId} = treeService.getNoteIdAndParentIdFromNotePath(notePath);
|
||||||
const targetBranchId = await treeCache.getBranchId(parentNoteId, noteId);
|
const targetBranchId = await froca.getBranchId(parentNoteId, noteId);
|
||||||
|
|
||||||
for (const cloneNoteId of clonedNoteIds) {
|
for (const cloneNoteId of clonedNoteIds) {
|
||||||
await branchService.cloneNoteTo(cloneNoteId, targetBranchId, $clonePrefix.val());
|
await branchService.cloneNoteTo(cloneNoteId, targetBranchId, $clonePrefix.val());
|
||||||
|
|
||||||
const clonedNote = await treeCache.getNote(cloneNoteId);
|
const clonedNote = await froca.getNote(cloneNoteId);
|
||||||
const targetNote = await treeCache.getBranch(targetBranchId).getNote();
|
const targetNote = await froca.getBranch(targetBranchId).getNote();
|
||||||
|
|
||||||
toastService.showMessage(`Note "${clonedNote.title}" has been cloned into ${targetNote.title}`);
|
toastService.showMessage(`Note "${clonedNote.title}" has been cloned into ${targetNote.title}`);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import server from "../services/server.js";
|
import server from "../services/server.js";
|
||||||
import treeCache from "../services/tree_cache.js";
|
import froca from "../services/tree_cache.js";
|
||||||
import linkService from "../services/link.js";
|
import linkService from "../services/link.js";
|
||||||
import utils from "../services/utils.js";
|
import utils from "../services/utils.js";
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ async function renderDeletePreview() {
|
|||||||
$deleteNotesListWrapper.toggle(response.noteIdsToBeDeleted.length > 0);
|
$deleteNotesListWrapper.toggle(response.noteIdsToBeDeleted.length > 0);
|
||||||
$noNoteToDeleteWrapper.toggle(response.noteIdsToBeDeleted.length === 0);
|
$noNoteToDeleteWrapper.toggle(response.noteIdsToBeDeleted.length === 0);
|
||||||
|
|
||||||
for (const note of await treeCache.getNotes(response.noteIdsToBeDeleted)) {
|
for (const note of await froca.getNotes(response.noteIdsToBeDeleted)) {
|
||||||
$deleteNotesList.append(
|
$deleteNotesList.append(
|
||||||
$("<li>").append(
|
$("<li>").append(
|
||||||
await linkService.createNoteLink(note.noteId, {showNotePath: true})
|
await linkService.createNoteLink(note.noteId, {showNotePath: true})
|
||||||
@ -43,7 +43,7 @@ async function renderDeletePreview() {
|
|||||||
$brokenRelationsListWrapper.toggle(response.brokenRelations.length > 0);
|
$brokenRelationsListWrapper.toggle(response.brokenRelations.length > 0);
|
||||||
$brokenRelationsCount.text(response.brokenRelations.length);
|
$brokenRelationsCount.text(response.brokenRelations.length);
|
||||||
|
|
||||||
await treeCache.getNotes(response.brokenRelations.map(br => br.noteId));
|
await froca.getNotes(response.brokenRelations.map(br => br.noteId));
|
||||||
|
|
||||||
for (const attr of response.brokenRelations) {
|
for (const attr of response.brokenRelations) {
|
||||||
$brokenRelationsList.append(
|
$brokenRelationsList.append(
|
||||||
|
@ -2,7 +2,7 @@ import treeService from "../services/tree.js";
|
|||||||
import utils from "../services/utils.js";
|
import utils from "../services/utils.js";
|
||||||
import ws from "../services/ws.js";
|
import ws from "../services/ws.js";
|
||||||
import toastService from "../services/toast.js";
|
import toastService from "../services/toast.js";
|
||||||
import treeCache from "../services/tree_cache.js";
|
import froca from "../services/tree_cache.js";
|
||||||
import openService from "../services/open.js";
|
import openService from "../services/open.js";
|
||||||
|
|
||||||
const $dialog = $("#export-dialog");
|
const $dialog = $("#export-dialog");
|
||||||
@ -42,7 +42,7 @@ export async function showDialog(notePath, defaultType) {
|
|||||||
|
|
||||||
const {noteId, parentNoteId} = treeService.getNoteIdAndParentIdFromNotePath(notePath);
|
const {noteId, parentNoteId} = treeService.getNoteIdAndParentIdFromNotePath(notePath);
|
||||||
|
|
||||||
branchId = await treeCache.getBranchId(parentNoteId, noteId);
|
branchId = await froca.getBranchId(parentNoteId, noteId);
|
||||||
|
|
||||||
const noteTitle = await treeService.getNoteTitle(noteId);
|
const noteTitle = await treeService.getNoteTitle(noteId);
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import treeService from '../services/tree.js';
|
import treeService from '../services/tree.js';
|
||||||
import noteAutocompleteService from '../services/note_autocomplete.js';
|
import noteAutocompleteService from '../services/note_autocomplete.js';
|
||||||
import utils from "../services/utils.js";
|
import utils from "../services/utils.js";
|
||||||
import treeCache from "../services/tree_cache.js";
|
import froca from "../services/tree_cache.js";
|
||||||
|
|
||||||
const $dialog = $("#include-note-dialog");
|
const $dialog = $("#include-note-dialog");
|
||||||
const $form = $("#include-note-form");
|
const $form = $("#include-note-form");
|
||||||
@ -26,7 +26,7 @@ export async function showDialog(widget) {
|
|||||||
|
|
||||||
async function includeNote(notePath) {
|
async function includeNote(notePath) {
|
||||||
const noteId = treeService.getNoteIdFromNotePath(notePath);
|
const noteId = treeService.getNoteIdFromNotePath(notePath);
|
||||||
const note = await treeCache.getNote(noteId);
|
const note = await froca.getNote(noteId);
|
||||||
|
|
||||||
const boxSize = $("input[name='include-note-box-size']:checked").val();
|
const boxSize = $("input[name='include-note-box-size']:checked").val();
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import noteAutocompleteService from "../services/note_autocomplete.js";
|
import noteAutocompleteService from "../services/note_autocomplete.js";
|
||||||
import utils from "../services/utils.js";
|
import utils from "../services/utils.js";
|
||||||
import toastService from "../services/toast.js";
|
import toastService from "../services/toast.js";
|
||||||
import treeCache from "../services/tree_cache.js";
|
import froca from "../services/tree_cache.js";
|
||||||
import branchService from "../services/branches.js";
|
import branchService from "../services/branches.js";
|
||||||
import treeService from "../services/tree.js";
|
import treeService from "../services/tree.js";
|
||||||
|
|
||||||
@ -22,8 +22,8 @@ export async function showDialog(branchIds) {
|
|||||||
$noteList.empty();
|
$noteList.empty();
|
||||||
|
|
||||||
for (const branchId of movedBranchIds) {
|
for (const branchId of movedBranchIds) {
|
||||||
const branch = treeCache.getBranch(branchId);
|
const branch = froca.getBranch(branchId);
|
||||||
const note = await treeCache.getNote(branch.noteId);
|
const note = await froca.getNote(branch.noteId);
|
||||||
|
|
||||||
$noteList.append($("<li>").text(note.title));
|
$noteList.append($("<li>").text(note.title));
|
||||||
}
|
}
|
||||||
@ -35,7 +35,7 @@ export async function showDialog(branchIds) {
|
|||||||
async function moveNotesTo(parentBranchId) {
|
async function moveNotesTo(parentBranchId) {
|
||||||
await branchService.moveToParentNote(movedBranchIds, parentBranchId);
|
await branchService.moveToParentNote(movedBranchIds, parentBranchId);
|
||||||
|
|
||||||
const parentBranch = treeCache.getBranch(parentBranchId);
|
const parentBranch = froca.getBranch(parentBranchId);
|
||||||
const parentNote = await parentBranch.getNote();
|
const parentNote = await parentBranch.getNote();
|
||||||
|
|
||||||
toastService.showMessage(`Selected notes have been moved into ${parentNote.title}`);
|
toastService.showMessage(`Selected notes have been moved into ${parentNote.title}`);
|
||||||
@ -48,7 +48,7 @@ $form.on('submit', () => {
|
|||||||
$dialog.modal('hide');
|
$dialog.modal('hide');
|
||||||
|
|
||||||
const {noteId, parentNoteId} = treeService.getNoteIdAndParentIdFromNotePath(notePath);
|
const {noteId, parentNoteId} = treeService.getNoteIdAndParentIdFromNotePath(notePath);
|
||||||
treeCache.getBranchId(parentNoteId, noteId).then(branchId => moveNotesTo(branchId));
|
froca.getBranchId(parentNoteId, noteId).then(branchId => moveNotesTo(branchId));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
logError("No path to move to.");
|
logError("No path to move to.");
|
||||||
|
@ -2,7 +2,7 @@ import linkService from '../services/link.js';
|
|||||||
import utils from '../services/utils.js';
|
import utils from '../services/utils.js';
|
||||||
import server from '../services/server.js';
|
import server from '../services/server.js';
|
||||||
import treeService from "../services/tree.js";
|
import treeService from "../services/tree.js";
|
||||||
import treeCache from "../services/tree_cache.js";
|
import froca from "../services/tree_cache.js";
|
||||||
import appContext from "../services/app_context.js";
|
import appContext from "../services/app_context.js";
|
||||||
import hoistedNoteService from "../services/hoisted_note.js";
|
import hoistedNoteService from "../services/hoisted_note.js";
|
||||||
|
|
||||||
@ -19,7 +19,7 @@ export async function showDialog(ancestorNoteId) {
|
|||||||
const recentChangesRows = await server.get('recent-changes/' + ancestorNoteId);
|
const recentChangesRows = await server.get('recent-changes/' + ancestorNoteId);
|
||||||
|
|
||||||
// preload all notes into cache
|
// preload all notes into cache
|
||||||
await treeCache.getNotes(recentChangesRows.map(r => r.noteId), true);
|
await froca.getNotes(recentChangesRows.map(r => r.noteId), true);
|
||||||
|
|
||||||
$content.empty();
|
$content.empty();
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ export async function showDialog(ancestorNoteId) {
|
|||||||
|
|
||||||
$dialog.modal('hide');
|
$dialog.modal('hide');
|
||||||
|
|
||||||
await treeCache.reloadNotes([change.noteId]);
|
await froca.reloadNotes([change.noteId]);
|
||||||
|
|
||||||
appContext.tabManager.getActiveTabContext().setNote(change.noteId);
|
appContext.tabManager.getActiveTabContext().setNote(change.noteId);
|
||||||
}
|
}
|
||||||
@ -67,7 +67,7 @@ export async function showDialog(ancestorNoteId) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const note = await treeCache.getNote(change.noteId);
|
const note = await froca.getNote(change.noteId);
|
||||||
const notePath = treeService.getSomeNotePath(note);
|
const notePath = treeService.getSomeNotePath(note);
|
||||||
|
|
||||||
if (notePath) {
|
if (notePath) {
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import promotedAttributeDefinitionParser from '../services/promoted_attribute_definition_parser.js';
|
import promotedAttributeDefinitionParser from '../services/promoted_attribute_definition_parser.js';
|
||||||
|
|
||||||
class Attribute {
|
class Attribute {
|
||||||
constructor(treeCache, row) {
|
constructor(froca, row) {
|
||||||
this.treeCache = treeCache;
|
this.froca = froca;
|
||||||
|
|
||||||
this.update(row);
|
this.update(row);
|
||||||
}
|
}
|
||||||
@ -28,7 +28,7 @@ class Attribute {
|
|||||||
|
|
||||||
/** @returns {NoteShort} */
|
/** @returns {NoteShort} */
|
||||||
getNote() {
|
getNote() {
|
||||||
return this.treeCache.notes[this.noteId];
|
return this.froca.notes[this.noteId];
|
||||||
}
|
}
|
||||||
|
|
||||||
get targetNoteId() { // alias
|
get targetNoteId() { // alias
|
||||||
@ -95,7 +95,7 @@ class Attribute {
|
|||||||
|
|
||||||
get dto() {
|
get dto() {
|
||||||
const dto = Object.assign({}, this);
|
const dto = Object.assign({}, this);
|
||||||
delete dto.treeCache;
|
delete dto.froca;
|
||||||
|
|
||||||
return dto;
|
return dto;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/** Represents mapping between note and parent note */
|
/** Represents mapping between note and parent note */
|
||||||
class Branch {
|
class Branch {
|
||||||
constructor(treeCache, row) {
|
constructor(froca, row) {
|
||||||
this.treeCache = treeCache;
|
this.froca = froca;
|
||||||
|
|
||||||
this.update(row);
|
this.update(row);
|
||||||
}
|
}
|
||||||
@ -27,17 +27,17 @@ class Branch {
|
|||||||
|
|
||||||
/** @returns {NoteShort} */
|
/** @returns {NoteShort} */
|
||||||
async getNote() {
|
async getNote() {
|
||||||
return this.treeCache.getNote(this.noteId);
|
return this.froca.getNote(this.noteId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @returns {NoteShort} */
|
/** @returns {NoteShort} */
|
||||||
getNoteFromCache() {
|
getNoteFromCache() {
|
||||||
return this.treeCache.getNoteFromCache(this.noteId);
|
return this.froca.getNoteFromCache(this.noteId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @returns {NoteShort} */
|
/** @returns {NoteShort} */
|
||||||
async getParentNote() {
|
async getParentNote() {
|
||||||
return this.treeCache.getNote(this.parentNoteId);
|
return this.froca.getNote(this.parentNoteId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @returns {boolean} true if it's top level, meaning its parent is root note */
|
/** @returns {boolean} true if it's top level, meaning its parent is root note */
|
||||||
|
@ -2,7 +2,7 @@ import server from '../services/server.js';
|
|||||||
import noteAttributeCache from "../services/note_attribute_cache.js";
|
import noteAttributeCache from "../services/note_attribute_cache.js";
|
||||||
import ws from "../services/ws.js";
|
import ws from "../services/ws.js";
|
||||||
import options from "../services/options.js";
|
import options from "../services/options.js";
|
||||||
import treeCache from "../services/tree_cache.js";
|
import froca from "../services/tree_cache.js";
|
||||||
|
|
||||||
const LABEL = 'label';
|
const LABEL = 'label';
|
||||||
const RELATION = 'relation';
|
const RELATION = 'relation';
|
||||||
@ -20,15 +20,15 @@ const NOTE_TYPE_ICONS = {
|
|||||||
/**
|
/**
|
||||||
* FIXME: since there's no "full note" anymore we can rename this to Note
|
* FIXME: since there's no "full note" anymore we can rename this to Note
|
||||||
*
|
*
|
||||||
* This note's representation is used in note tree and is kept in TreeCache.
|
* This note's representation is used in note tree and is kept in Froca.
|
||||||
*/
|
*/
|
||||||
class NoteShort {
|
class NoteShort {
|
||||||
/**
|
/**
|
||||||
* @param {TreeCache} treeCache
|
* @param {Froca} froca
|
||||||
* @param {Object.<string, Object>} row
|
* @param {Object.<string, Object>} row
|
||||||
*/
|
*/
|
||||||
constructor(treeCache, row) {
|
constructor(froca, row) {
|
||||||
this.treeCache = treeCache;
|
this.froca = froca;
|
||||||
|
|
||||||
/** @type {string[]} */
|
/** @type {string[]} */
|
||||||
this.attributes = [];
|
this.attributes = [];
|
||||||
@ -93,7 +93,7 @@ class NoteShort {
|
|||||||
const branchIdPos = {};
|
const branchIdPos = {};
|
||||||
|
|
||||||
for (const branchId of Object.values(this.childToBranch)) {
|
for (const branchId of Object.values(this.childToBranch)) {
|
||||||
branchIdPos[branchId] = this.treeCache.getBranch(branchId).notePosition;
|
branchIdPos[branchId] = this.froca.getBranch(branchId).notePosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.children.sort((a, b) => branchIdPos[this.childToBranch[a]] < branchIdPos[this.childToBranch[b]] ? -1 : 1);
|
this.children.sort((a, b) => branchIdPos[this.childToBranch[a]] < branchIdPos[this.childToBranch[b]] ? -1 : 1);
|
||||||
@ -105,7 +105,7 @@ class NoteShort {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getContent() {
|
async getContent() {
|
||||||
// we're not caching content since these objects are in treeCache and as such pretty long lived
|
// we're not caching content since these objects are in froca and as such pretty long lived
|
||||||
const note = await server.get("notes/" + this.noteId);
|
const note = await server.get("notes/" + this.noteId);
|
||||||
|
|
||||||
return note.content;
|
return note.content;
|
||||||
@ -133,7 +133,7 @@ class NoteShort {
|
|||||||
getBranches() {
|
getBranches() {
|
||||||
const branchIds = Object.values(this.parentToBranch);
|
const branchIds = Object.values(this.parentToBranch);
|
||||||
|
|
||||||
return this.treeCache.getBranches(branchIds);
|
return this.froca.getBranches(branchIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @returns {boolean} */
|
/** @returns {boolean} */
|
||||||
@ -146,7 +146,7 @@ class NoteShort {
|
|||||||
// 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]);
|
||||||
|
|
||||||
return this.treeCache.getBranches(branchIds);
|
return this.froca.getBranches(branchIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @returns {string[]} */
|
/** @returns {string[]} */
|
||||||
@ -156,7 +156,7 @@ class NoteShort {
|
|||||||
|
|
||||||
/** @returns {NoteShort[]} */
|
/** @returns {NoteShort[]} */
|
||||||
getParentNotes() {
|
getParentNotes() {
|
||||||
return this.treeCache.getNotesFromCache(this.parents);
|
return this.froca.getNotesFromCache(this.parents);
|
||||||
}
|
}
|
||||||
|
|
||||||
// will sort the parents so that non-search & non-archived are first and archived at the end
|
// will sort the parents so that non-search & non-archived are first and archived at the end
|
||||||
@ -169,7 +169,7 @@ class NoteShort {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
const aNote = this.treeCache.getNoteFromCache([aNoteId]);
|
const aNote = this.froca.getNoteFromCache([aNoteId]);
|
||||||
|
|
||||||
if (aNote.hasLabel('archived')) {
|
if (aNote.hasLabel('archived')) {
|
||||||
return 1;
|
return 1;
|
||||||
@ -186,7 +186,7 @@ class NoteShort {
|
|||||||
|
|
||||||
/** @returns {Promise<NoteShort[]>} */
|
/** @returns {Promise<NoteShort[]>} */
|
||||||
async getChildNotes() {
|
async getChildNotes() {
|
||||||
return await this.treeCache.getNotes(this.children);
|
return await this.froca.getNotes(this.children);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -196,7 +196,7 @@ class NoteShort {
|
|||||||
*/
|
*/
|
||||||
getOwnedAttributes(type, name) {
|
getOwnedAttributes(type, name) {
|
||||||
const attrs = this.attributes
|
const attrs = this.attributes
|
||||||
.map(attributeId => this.treeCache.attributes[attributeId])
|
.map(attributeId => this.froca.attributes[attributeId])
|
||||||
.filter(Boolean); // filter out nulls;
|
.filter(Boolean); // filter out nulls;
|
||||||
|
|
||||||
return this.__filterAttrs(attrs, type, name);
|
return this.__filterAttrs(attrs, type, name);
|
||||||
@ -224,7 +224,7 @@ class NoteShort {
|
|||||||
|
|
||||||
if (this.noteId !== 'root') {
|
if (this.noteId !== 'root') {
|
||||||
for (const parentNote of this.getParentNotes()) {
|
for (const parentNote of this.getParentNotes()) {
|
||||||
// these virtual parent-child relationships are also loaded into frontend tree cache
|
// these virtual parent-child relationships are also loaded into froca
|
||||||
if (parentNote.type !== 'search') {
|
if (parentNote.type !== 'search') {
|
||||||
attrArrs.push(parentNote.__getInheritableAttributes(newPath));
|
attrArrs.push(parentNote.__getInheritableAttributes(newPath));
|
||||||
}
|
}
|
||||||
@ -232,7 +232,7 @@ class NoteShort {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (const templateAttr of attrArrs.flat().filter(attr => attr.type === 'relation' && attr.name === 'template')) {
|
for (const templateAttr of attrArrs.flat().filter(attr => attr.type === 'relation' && attr.name === 'template')) {
|
||||||
const templateNote = this.treeCache.notes[templateAttr.value];
|
const templateNote = this.froca.notes[templateAttr.value];
|
||||||
|
|
||||||
if (templateNote && templateNote.noteId !== this.noteId) {
|
if (templateNote && templateNote.noteId !== this.noteId) {
|
||||||
attrArrs.push(templateNote.__getCachedAttributes(newPath));
|
attrArrs.push(templateNote.__getCachedAttributes(newPath));
|
||||||
@ -301,8 +301,8 @@ class NoteShort {
|
|||||||
const notePaths = this.getAllNotePaths().map(path => ({
|
const notePaths = this.getAllNotePaths().map(path => ({
|
||||||
notePath: path,
|
notePath: path,
|
||||||
isInHoistedSubTree: path.includes(hoistedNotePath),
|
isInHoistedSubTree: path.includes(hoistedNotePath),
|
||||||
isArchived: path.find(noteId => treeCache.notes[noteId].hasLabel('archived')),
|
isArchived: path.find(noteId => froca.notes[noteId].hasLabel('archived')),
|
||||||
isSearch: path.find(noteId => treeCache.notes[noteId].type === 'search')
|
isSearch: path.find(noteId => froca.notes[noteId].type === 'search')
|
||||||
}));
|
}));
|
||||||
|
|
||||||
notePaths.sort((a, b) => {
|
notePaths.sort((a, b) => {
|
||||||
@ -580,7 +580,7 @@ class NoteShort {
|
|||||||
const targets = [];
|
const targets = [];
|
||||||
|
|
||||||
for (const relation of relations) {
|
for (const relation of relations) {
|
||||||
targets.push(await this.treeCache.getNote(relation.value));
|
targets.push(await this.froca.getNote(relation.value));
|
||||||
}
|
}
|
||||||
|
|
||||||
return targets;
|
return targets;
|
||||||
@ -592,7 +592,7 @@ class NoteShort {
|
|||||||
getTemplateNotes() {
|
getTemplateNotes() {
|
||||||
const relations = this.getRelations('template');
|
const relations = this.getRelations('template');
|
||||||
|
|
||||||
return relations.map(rel => this.treeCache.notes[rel.value]);
|
return relations.map(rel => this.froca.notes[rel.value]);
|
||||||
}
|
}
|
||||||
|
|
||||||
getPromotedDefinitionAttributes() {
|
getPromotedDefinitionAttributes() {
|
||||||
@ -653,7 +653,7 @@ class NoteShort {
|
|||||||
*/
|
*/
|
||||||
getTargetRelations() {
|
getTargetRelations() {
|
||||||
return this.targetRelations
|
return this.targetRelations
|
||||||
.map(attributeId => this.treeCache.attributes[attributeId]);
|
.map(attributeId => this.froca.attributes[attributeId]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -664,7 +664,7 @@ class NoteShort {
|
|||||||
async getTargetRelationSourceNotes() {
|
async getTargetRelationSourceNotes() {
|
||||||
const targetRelations = this.getTargetRelations();
|
const targetRelations = this.getTargetRelations();
|
||||||
|
|
||||||
return await this.treeCache.getNotes(targetRelations.map(tr => tr.noteId));
|
return await this.froca.getNotes(targetRelations.map(tr => tr.noteId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -673,7 +673,7 @@ class NoteShort {
|
|||||||
* @return {Promise<NoteComplement>}
|
* @return {Promise<NoteComplement>}
|
||||||
*/
|
*/
|
||||||
async getNoteComplement() {
|
async getNoteComplement() {
|
||||||
return await this.treeCache.getNoteComplement(this.noteId);
|
return await this.froca.getNoteComplement(this.noteId);
|
||||||
}
|
}
|
||||||
|
|
||||||
get toString() {
|
get toString() {
|
||||||
@ -682,7 +682,7 @@ class NoteShort {
|
|||||||
|
|
||||||
get dto() {
|
get dto() {
|
||||||
const dto = Object.assign({}, this);
|
const dto = Object.assign({}, this);
|
||||||
delete dto.treeCache;
|
delete dto.froca;
|
||||||
|
|
||||||
return dto;
|
return dto;
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import treeCache from "./tree_cache.js";
|
import froca from "./tree_cache.js";
|
||||||
import bundleService from "./bundle.js";
|
import bundleService from "./bundle.js";
|
||||||
import DialogCommandExecutor from "./dialog_command_executor.js";
|
import DialogCommandExecutor from "./dialog_command_executor.js";
|
||||||
import Entrypoints from "./entrypoints.js";
|
import Entrypoints from "./entrypoints.js";
|
||||||
@ -28,7 +28,7 @@ class AppContext extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async start() {
|
async start() {
|
||||||
await Promise.all([treeCache.initializedPromise, options.initializedPromise]);
|
await Promise.all([froca.initializedPromise, options.initializedPromise]);
|
||||||
|
|
||||||
this.showWidgets();
|
this.showWidgets();
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import ws from "./ws.js";
|
import ws from "./ws.js";
|
||||||
import treeCache from "./tree_cache.js";
|
import froca from "./tree_cache.js";
|
||||||
|
|
||||||
async function renderAttribute(attribute, renderIsInheritable) {
|
async function renderAttribute(attribute, renderIsInheritable) {
|
||||||
const isInheritable = renderIsInheritable && attribute.isInheritable ? `(inheritable)` : '';
|
const isInheritable = renderIsInheritable && attribute.isInheritable ? `(inheritable)` : '';
|
||||||
@ -48,7 +48,7 @@ function formatValue(val) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function createNoteLink(noteId) {
|
async function createNoteLink(noteId) {
|
||||||
const note = await treeCache.getNote(noteId);
|
const note = await froca.getNote(noteId);
|
||||||
|
|
||||||
if (!note) {
|
if (!note) {
|
||||||
return;
|
return;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import utils from './utils.js';
|
import utils from './utils.js';
|
||||||
import server from './server.js';
|
import server from './server.js';
|
||||||
import toastService from "./toast.js";
|
import toastService from "./toast.js";
|
||||||
import treeCache from "./tree_cache.js";
|
import froca from "./tree_cache.js";
|
||||||
import hoistedNoteService from "./hoisted_note.js";
|
import hoistedNoteService from "./hoisted_note.js";
|
||||||
import ws from "./ws.js";
|
import ws from "./ws.js";
|
||||||
|
|
||||||
@ -28,7 +28,7 @@ async function moveAfterBranch(branchIdsToMove, afterBranchId) {
|
|||||||
branchIdsToMove = filterRootNote(branchIdsToMove);
|
branchIdsToMove = filterRootNote(branchIdsToMove);
|
||||||
branchIdsToMove = filterSearchBranches(branchIdsToMove);
|
branchIdsToMove = filterSearchBranches(branchIdsToMove);
|
||||||
|
|
||||||
const afterNote = await treeCache.getBranch(afterBranchId).getNote();
|
const afterNote = await froca.getBranch(afterBranchId).getNote();
|
||||||
|
|
||||||
if (afterNote.noteId === 'root' || afterNote.noteId === hoistedNoteService.getHoistedNoteId()) {
|
if (afterNote.noteId === 'root' || afterNote.noteId === hoistedNoteService.getHoistedNoteId()) {
|
||||||
alert('Cannot move notes after root note.');
|
alert('Cannot move notes after root note.');
|
||||||
@ -51,7 +51,7 @@ async function moveToParentNote(branchIdsToMove, newParentBranchId) {
|
|||||||
branchIdsToMove = filterRootNote(branchIdsToMove);
|
branchIdsToMove = filterRootNote(branchIdsToMove);
|
||||||
|
|
||||||
for (const branchIdToMove of branchIdsToMove) {
|
for (const branchIdToMove of branchIdsToMove) {
|
||||||
const branchToMove = treeCache.getBranch(branchIdToMove);
|
const branchToMove = froca.getBranch(branchIdToMove);
|
||||||
|
|
||||||
if (branchToMove.noteId === hoistedNoteService.getHoistedNoteId()
|
if (branchToMove.noteId === hoistedNoteService.getHoistedNoteId()
|
||||||
|| (await branchToMove.getParentNote()).type === 'search') {
|
|| (await branchToMove.getParentNote()).type === 'search') {
|
||||||
@ -91,7 +91,7 @@ async function deleteNotes(branchIdsToDelete) {
|
|||||||
const last = counter === branchIdsToDelete.length;
|
const last = counter === branchIdsToDelete.length;
|
||||||
const query = `?taskId=${taskId}&last=${last ? 'true' : 'false'}`;
|
const query = `?taskId=${taskId}&last=${last ? 'true' : 'false'}`;
|
||||||
|
|
||||||
const branch = treeCache.getBranch(branchIdToDelete);
|
const branch = froca.getBranch(branchIdToDelete);
|
||||||
|
|
||||||
if (deleteAllClones) {
|
if (deleteAllClones) {
|
||||||
await server.remove(`notes/${branch.noteId}` + query);
|
await server.remove(`notes/${branch.noteId}` + query);
|
||||||
@ -132,7 +132,7 @@ function filterRootNote(branchIds) {
|
|||||||
const hoistedNoteId = hoistedNoteService.getHoistedNoteId();
|
const hoistedNoteId = hoistedNoteService.getHoistedNoteId();
|
||||||
|
|
||||||
return branchIds.filter(branchId => {
|
return branchIds.filter(branchId => {
|
||||||
const branch = treeCache.getBranch(branchId);
|
const branch = froca.getBranch(branchId);
|
||||||
|
|
||||||
return branch.noteId !== 'root'
|
return branch.noteId !== 'root'
|
||||||
&& branch.noteId !== hoistedNoteId;
|
&& branch.noteId !== hoistedNoteId;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import ScriptContext from "./script_context.js";
|
import ScriptContext from "./script_context.js";
|
||||||
import server from "./server.js";
|
import server from "./server.js";
|
||||||
import toastService from "./toast.js";
|
import toastService from "./toast.js";
|
||||||
import treeCache from "./tree_cache.js";
|
import froca from "./tree_cache.js";
|
||||||
import utils from "./utils.js";
|
import utils from "./utils.js";
|
||||||
|
|
||||||
async function getAndExecuteBundle(noteId, originEntity = null) {
|
async function getAndExecuteBundle(noteId, originEntity = null) {
|
||||||
@ -19,7 +19,7 @@ async function executeBundle(bundle, originEntity, $container) {
|
|||||||
}.call(apiContext));
|
}.call(apiContext));
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
const note = await treeCache.getNote(bundle.noteId);
|
const note = await froca.getNote(bundle.noteId);
|
||||||
|
|
||||||
toastService.showAndLogError(`Execution of JS note "${note.title}" with ID ${bundle.noteId} failed with error: ${e.message}`);
|
toastService.showAndLogError(`Execution of JS note "${note.title}" with ID ${bundle.noteId} failed with error: ${e.message}`);
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import branchService from "./branches.js";
|
import branchService from "./branches.js";
|
||||||
import toastService from "./toast.js";
|
import toastService from "./toast.js";
|
||||||
import hoistedNoteService from "./hoisted_note.js";
|
import hoistedNoteService from "./hoisted_note.js";
|
||||||
import treeCache from "./tree_cache.js";
|
import froca from "./tree_cache.js";
|
||||||
|
|
||||||
let clipboardBranchIds = [];
|
let clipboardBranchIds = [];
|
||||||
let clipboardMode = null;
|
let clipboardMode = null;
|
||||||
@ -18,7 +18,7 @@ async function pasteAfter(afterBranchId) {
|
|||||||
clipboardMode = null;
|
clipboardMode = null;
|
||||||
}
|
}
|
||||||
else if (clipboardMode === 'copy') {
|
else if (clipboardMode === 'copy') {
|
||||||
const clipboardBranches = clipboardBranchIds.map(branchId => treeCache.getBranch(branchId));
|
const clipboardBranches = clipboardBranchIds.map(branchId => froca.getBranch(branchId));
|
||||||
|
|
||||||
for (const clipboardBranch of clipboardBranches) {
|
for (const clipboardBranch of clipboardBranches) {
|
||||||
const clipboardNote = await clipboardBranch.getNote();
|
const clipboardNote = await clipboardBranch.getNote();
|
||||||
@ -45,7 +45,7 @@ async function pasteInto(parentBranchId) {
|
|||||||
clipboardMode = null;
|
clipboardMode = null;
|
||||||
}
|
}
|
||||||
else if (clipboardMode === 'copy') {
|
else if (clipboardMode === 'copy') {
|
||||||
const clipboardBranches = clipboardBranchIds.map(branchId => treeCache.getBranch(branchId));
|
const clipboardBranches = clipboardBranchIds.map(branchId => froca.getBranch(branchId));
|
||||||
|
|
||||||
for (const clipboardBranch of clipboardBranches) {
|
for (const clipboardBranch of clipboardBranches) {
|
||||||
const clipboardNote = await clipboardBranch.getNote();
|
const clipboardNote = await clipboardBranch.getNote();
|
||||||
@ -78,7 +78,7 @@ function cut(branchIds) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function isClipboardEmpty() {
|
function isClipboardEmpty() {
|
||||||
clipboardBranchIds = clipboardBranchIds.filter(branchId => !!treeCache.getBranch(branchId));
|
clipboardBranchIds = clipboardBranchIds.filter(branchId => !!froca.getBranch(branchId));
|
||||||
|
|
||||||
return clipboardBranchIds.length === 0;
|
return clipboardBranchIds.length === 0;
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import treeCache from "./tree_cache.js";
|
import froca from "./tree_cache.js";
|
||||||
import server from "./server.js";
|
import server from "./server.js";
|
||||||
import ws from "./ws.js";
|
import ws from "./ws.js";
|
||||||
|
|
||||||
@ -6,7 +6,7 @@ import ws from "./ws.js";
|
|||||||
async function getInboxNote() {
|
async function getInboxNote() {
|
||||||
const note = await server.get('date-notes/inbox/' + dayjs().format("YYYY-MM-DD"), "date-note");
|
const note = await server.get('date-notes/inbox/' + dayjs().format("YYYY-MM-DD"), "date-note");
|
||||||
|
|
||||||
return await treeCache.getNote(note.noteId);
|
return await froca.getNote(note.noteId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return {NoteShort} */
|
/** @return {NoteShort} */
|
||||||
@ -20,7 +20,7 @@ async function getDateNote(date) {
|
|||||||
|
|
||||||
await ws.waitForMaxKnownEntityChangeId();
|
await ws.waitForMaxKnownEntityChangeId();
|
||||||
|
|
||||||
return await treeCache.getNote(note.noteId);
|
return await froca.getNote(note.noteId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return {NoteShort} */
|
/** @return {NoteShort} */
|
||||||
@ -29,7 +29,7 @@ async function getMonthNote(month) {
|
|||||||
|
|
||||||
await ws.waitForMaxKnownEntityChangeId();
|
await ws.waitForMaxKnownEntityChangeId();
|
||||||
|
|
||||||
return await treeCache.getNote(note.noteId);
|
return await froca.getNote(note.noteId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return {NoteShort} */
|
/** @return {NoteShort} */
|
||||||
@ -38,7 +38,7 @@ async function getYearNote(year) {
|
|||||||
|
|
||||||
await ws.waitForMaxKnownEntityChangeId();
|
await ws.waitForMaxKnownEntityChangeId();
|
||||||
|
|
||||||
return await treeCache.getNote(note.noteId);
|
return await froca.getNote(note.noteId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return {NoteShort} */
|
/** @return {NoteShort} */
|
||||||
@ -47,7 +47,7 @@ async function createSqlConsole() {
|
|||||||
|
|
||||||
await ws.waitForMaxKnownEntityChangeId();
|
await ws.waitForMaxKnownEntityChangeId();
|
||||||
|
|
||||||
return await treeCache.getNote(note.noteId);
|
return await froca.getNote(note.noteId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return {NoteShort} */
|
/** @return {NoteShort} */
|
||||||
@ -56,7 +56,7 @@ async function createSearchNote(opts = {}) {
|
|||||||
|
|
||||||
await ws.waitForMaxKnownEntityChangeId();
|
await ws.waitForMaxKnownEntityChangeId();
|
||||||
|
|
||||||
return await treeCache.getNote(note.noteId);
|
return await froca.getNote(note.noteId);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
@ -2,7 +2,7 @@ import server from './server.js';
|
|||||||
import utils from './utils.js';
|
import utils from './utils.js';
|
||||||
import toastService from './toast.js';
|
import toastService from './toast.js';
|
||||||
import linkService from './link.js';
|
import linkService from './link.js';
|
||||||
import treeCache from './tree_cache.js';
|
import froca from './tree_cache.js';
|
||||||
import noteTooltipService from './note_tooltip.js';
|
import noteTooltipService from './note_tooltip.js';
|
||||||
import protectedSessionService from './protected_session.js';
|
import protectedSessionService from './protected_session.js';
|
||||||
import dateNotesService from './date_notes.js';
|
import dateNotesService from './date_notes.js';
|
||||||
@ -223,7 +223,7 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain
|
|||||||
* @param {string} noteId
|
* @param {string} noteId
|
||||||
* @return {Promise<NoteShort>}
|
* @return {Promise<NoteShort>}
|
||||||
*/
|
*/
|
||||||
this.getNote = async noteId => await treeCache.getNote(noteId);
|
this.getNote = async noteId => await froca.getNote(noteId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns list of notes. If note is missing from cache, it's loaded.
|
* Returns list of notes. If note is missing from cache, it's loaded.
|
||||||
@ -235,7 +235,7 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain
|
|||||||
* @param {boolean} [silentNotFoundError] - don't report error if the note is not found
|
* @param {boolean} [silentNotFoundError] - don't report error if the note is not found
|
||||||
* @return {Promise<NoteShort[]>}
|
* @return {Promise<NoteShort[]>}
|
||||||
*/
|
*/
|
||||||
this.getNotes = async (noteIds, silentNotFoundError = false) => await treeCache.getNotes(noteIds, silentNotFoundError);
|
this.getNotes = async (noteIds, silentNotFoundError = false) => await froca.getNotes(noteIds, silentNotFoundError);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update frontend tree (note) cache from the backend.
|
* Update frontend tree (note) cache from the backend.
|
||||||
@ -243,7 +243,7 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain
|
|||||||
* @param {string[]} noteIds
|
* @param {string[]} noteIds
|
||||||
* @method
|
* @method
|
||||||
*/
|
*/
|
||||||
this.reloadNotes = async noteIds => await treeCache.reloadNotes(noteIds);
|
this.reloadNotes = async noteIds => await froca.reloadNotes(noteIds);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instance name identifies particular Trilium instance. It can be useful for scripts
|
* Instance name identifies particular Trilium instance. It can be useful for scripts
|
||||||
|
@ -4,7 +4,7 @@ import server from "./server.js";
|
|||||||
import libraryLoader from "./library_loader.js";
|
import libraryLoader from "./library_loader.js";
|
||||||
import ws from "./ws.js";
|
import ws from "./ws.js";
|
||||||
import protectedSessionHolder from "./protected_session_holder.js";
|
import protectedSessionHolder from "./protected_session_holder.js";
|
||||||
import treeCache from "./tree_cache.js";
|
import froca from "./tree_cache.js";
|
||||||
|
|
||||||
function setupGlobs() {
|
function setupGlobs() {
|
||||||
window.glob.PROFILING_LOG = false;
|
window.glob.PROFILING_LOG = false;
|
||||||
@ -20,7 +20,7 @@ function setupGlobs() {
|
|||||||
window.glob.requireLibrary = libraryLoader.requireLibrary;
|
window.glob.requireLibrary = libraryLoader.requireLibrary;
|
||||||
window.glob.ESLINT = libraryLoader.ESLINT;
|
window.glob.ESLINT = libraryLoader.ESLINT;
|
||||||
window.glob.appContext = appContext; // for debugging
|
window.glob.appContext = appContext; // for debugging
|
||||||
window.glob.treeCache = treeCache;
|
window.glob.froca = froca;
|
||||||
|
|
||||||
// for CKEditor integration (button on block toolbar)
|
// for CKEditor integration (button on block toolbar)
|
||||||
window.glob.importMarkdownInline = async () => {
|
window.glob.importMarkdownInline = async () => {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import treeService from './tree.js';
|
import treeService from './tree.js';
|
||||||
import contextMenu from "./context_menu.js";
|
import contextMenu from "./context_menu.js";
|
||||||
import appContext from "./app_context.js";
|
import appContext from "./app_context.js";
|
||||||
import treeCache from "./tree_cache.js";
|
import froca from "./tree_cache.js";
|
||||||
import utils from "./utils.js";
|
import utils from "./utils.js";
|
||||||
|
|
||||||
function getNotePathFromUrl(url) {
|
function getNotePathFromUrl(url) {
|
||||||
@ -138,7 +138,7 @@ function linkContextMenu(e) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function loadReferenceLinkTitle(noteId, $el) {
|
async function loadReferenceLinkTitle(noteId, $el) {
|
||||||
const note = await treeCache.getNote(noteId, true);
|
const note = await froca.getNote(noteId, true);
|
||||||
|
|
||||||
let title;
|
let title;
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import libraryLoader from "./library_loader.js";
|
import libraryLoader from "./library_loader.js";
|
||||||
import server from "./server.js";
|
import server from "./server.js";
|
||||||
import treeCache from "./tree_cache.js";
|
import froca from "./tree_cache.js";
|
||||||
import linkService from "./link.js";
|
import linkService from "./link.js";
|
||||||
|
|
||||||
const linkOverlays = [
|
const linkOverlays = [
|
||||||
@ -63,14 +63,14 @@ export default class LinkMap {
|
|||||||
noteIds.add(this.note.noteId);
|
noteIds.add(this.note.noteId);
|
||||||
}
|
}
|
||||||
|
|
||||||
await treeCache.getNotes(Array.from(noteIds));
|
await froca.getNotes(Array.from(noteIds));
|
||||||
|
|
||||||
// pre-fetch the link titles, it's important to have hte construction afterwards synchronous
|
// pre-fetch the link titles, it's important to have hte construction afterwards synchronous
|
||||||
// since jsPlumb caculates width of the element
|
// since jsPlumb caculates width of the element
|
||||||
const $linkTitles = {};
|
const $linkTitles = {};
|
||||||
|
|
||||||
for (const noteId of noteIds) {
|
for (const noteId of noteIds) {
|
||||||
const note = await treeCache.getNote(noteId);
|
const note = await froca.getNote(noteId);
|
||||||
|
|
||||||
$linkTitles[noteId] = await linkService.createNoteLink(noteId, {title: note.title});
|
$linkTitles[noteId] = await linkService.createNoteLink(noteId, {title: note.title});
|
||||||
|
|
||||||
@ -85,7 +85,7 @@ export default class LinkMap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// preload all notes
|
// preload all notes
|
||||||
const notes = await treeCache.getNotes(Array.from(noteIds), true);
|
const notes = await froca.getNotes(Array.from(noteIds), true);
|
||||||
|
|
||||||
const graph = new Springy.Graph();
|
const graph = new Springy.Graph();
|
||||||
graph.addNodes(...noteIds);
|
graph.addNodes(...noteIds);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
export default class LoadResults {
|
export default class LoadResults {
|
||||||
constructor(treeCache) {
|
constructor(froca) {
|
||||||
this.treeCache = treeCache;
|
this.froca = froca;
|
||||||
|
|
||||||
this.noteIdToSourceId = {};
|
this.noteIdToSourceId = {};
|
||||||
this.sourceIdToNoteIds = {};
|
this.sourceIdToNoteIds = {};
|
||||||
@ -38,7 +38,7 @@ export default class LoadResults {
|
|||||||
|
|
||||||
getBranches() {
|
getBranches() {
|
||||||
return this.branches
|
return this.branches
|
||||||
.map(row => this.treeCache.branches[row.branchId])
|
.map(row => this.froca.branches[row.branchId])
|
||||||
.filter(branch => !!branch);
|
.filter(branch => !!branch);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ export default class LoadResults {
|
|||||||
getAttributes(sourceId = 'none') {
|
getAttributes(sourceId = 'none') {
|
||||||
return this.attributes
|
return this.attributes
|
||||||
.filter(row => row.sourceId !== sourceId)
|
.filter(row => row.sourceId !== sourceId)
|
||||||
.map(row => this.treeCache.attributes[row.attributeId])
|
.map(row => this.froca.attributes[row.attributeId])
|
||||||
.filter(attr => !!attr);
|
.filter(attr => !!attr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ import appContext from "./app_context.js";
|
|||||||
import utils from './utils.js';
|
import utils from './utils.js';
|
||||||
import noteCreateService from './note_create.js';
|
import noteCreateService from './note_create.js';
|
||||||
import treeService from './tree.js';
|
import treeService from './tree.js';
|
||||||
import treeCache from "./tree_cache.js";
|
import froca from "./tree_cache.js";
|
||||||
|
|
||||||
// this key needs to have this value so it's hit by the tooltip
|
// this key needs to have this value so it's hit by the tooltip
|
||||||
const SELECTED_NOTE_PATH_KEY = "data-note-path";
|
const SELECTED_NOTE_PATH_KEY = "data-note-path";
|
||||||
@ -252,7 +252,7 @@ function init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$.fn.setNote = async function (noteId) {
|
$.fn.setNote = async function (noteId) {
|
||||||
const note = noteId ? await treeCache.getNote(noteId, true) : null;
|
const note = noteId ? await froca.getNote(noteId, true) : null;
|
||||||
|
|
||||||
$(this)
|
$(this)
|
||||||
.val(note ? note.title : "")
|
.val(note ? note.title : "")
|
||||||
|
@ -4,7 +4,7 @@ import protectedSessionService from "./protected_session.js";
|
|||||||
import protectedSessionHolder from "./protected_session_holder.js";
|
import protectedSessionHolder from "./protected_session_holder.js";
|
||||||
import libraryLoader from "./library_loader.js";
|
import libraryLoader from "./library_loader.js";
|
||||||
import openService from "./open.js";
|
import openService from "./open.js";
|
||||||
import treeCache from "./tree_cache.js";
|
import froca from "./tree_cache.js";
|
||||||
|
|
||||||
async function getRenderedContent(note, options = {}) {
|
async function getRenderedContent(note, options = {}) {
|
||||||
options = Object.assign({
|
options = Object.assign({
|
||||||
@ -17,7 +17,7 @@ async function getRenderedContent(note, options = {}) {
|
|||||||
const $renderedContent = $('<div class="rendered-note-content">');
|
const $renderedContent = $('<div class="rendered-note-content">');
|
||||||
|
|
||||||
if (type === 'text') {
|
if (type === 'text') {
|
||||||
const noteComplement = await treeCache.getNoteComplement(note.noteId);
|
const noteComplement = await froca.getNoteComplement(note.noteId);
|
||||||
|
|
||||||
$renderedContent.append($('<div class="ck-content">').html(trim(noteComplement.content, options.trim)));
|
$renderedContent.append($('<div class="ck-content">').html(trim(noteComplement.content, options.trim)));
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ import utils from "./utils.js";
|
|||||||
import protectedSessionHolder from "./protected_session_holder.js";
|
import protectedSessionHolder from "./protected_session_holder.js";
|
||||||
import server from "./server.js";
|
import server from "./server.js";
|
||||||
import ws from "./ws.js";
|
import ws from "./ws.js";
|
||||||
import treeCache from "./tree_cache.js";
|
import froca from "./tree_cache.js";
|
||||||
import treeService from "./tree.js";
|
import treeService from "./tree.js";
|
||||||
import toastService from "./toast.js";
|
import toastService from "./toast.js";
|
||||||
|
|
||||||
@ -59,8 +59,8 @@ async function createNote(parentNotePath, options = {}) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const noteEntity = await treeCache.getNote(note.noteId);
|
const noteEntity = await froca.getNote(note.noteId);
|
||||||
const branchEntity = treeCache.getBranch(branch.branchId);
|
const branchEntity = froca.getBranch(branch.branchId);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
note: noteEntity,
|
note: noteEntity,
|
||||||
@ -93,7 +93,7 @@ async function duplicateSubtree(noteId, parentNotePath) {
|
|||||||
const activeTabContext = appContext.tabManager.getActiveTabContext();
|
const activeTabContext = appContext.tabManager.getActiveTabContext();
|
||||||
activeTabContext.setNote(`${parentNotePath}/${note.noteId}`);
|
activeTabContext.setNote(`${parentNotePath}/${note.noteId}`);
|
||||||
|
|
||||||
const origNote = await treeCache.getNote(noteId);
|
const origNote = await froca.getNote(noteId);
|
||||||
toastService.showMessage(`Note "${origNote.title}" has been duplicated`);
|
toastService.showMessage(`Note "${origNote.title}" has been duplicated`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import linkService from "./link.js";
|
import linkService from "./link.js";
|
||||||
import noteContentRenderer from "./note_content_renderer.js";
|
import noteContentRenderer from "./note_content_renderer.js";
|
||||||
import treeCache from "./tree_cache.js";
|
import froca from "./tree_cache.js";
|
||||||
import attributeService from "./attributes.js";
|
import attributeService from "./attributes.js";
|
||||||
import attributeRenderer from "./attribute_renderer.js";
|
import attributeRenderer from "./attribute_renderer.js";
|
||||||
|
|
||||||
@ -268,7 +268,7 @@ class NoteListRenderer {
|
|||||||
const endIdx = startIdx + this.pageSize;
|
const endIdx = startIdx + this.pageSize;
|
||||||
|
|
||||||
const pageNoteIds = this.noteIds.slice(startIdx, Math.min(endIdx, this.noteIds.length));
|
const pageNoteIds = this.noteIds.slice(startIdx, Math.min(endIdx, this.noteIds.length));
|
||||||
const pageNotes = await treeCache.getNotes(pageNoteIds);
|
const pageNotes = await froca.getNotes(pageNoteIds);
|
||||||
|
|
||||||
for (const note of pageNotes) {
|
for (const note of pageNotes) {
|
||||||
const $card = await this.renderNote(note, this.parentNote.hasLabel('expanded'));
|
const $card = await this.renderNote(note, this.parentNote.hasLabel('expanded'));
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import treeService from "./tree.js";
|
import treeService from "./tree.js";
|
||||||
import linkService from "./link.js";
|
import linkService from "./link.js";
|
||||||
import treeCache from "./tree_cache.js";
|
import froca from "./tree_cache.js";
|
||||||
import utils from "./utils.js";
|
import utils from "./utils.js";
|
||||||
import attributeRenderer from "./attribute_renderer.js";
|
import attributeRenderer from "./attribute_renderer.js";
|
||||||
import noteContentRenderer from "./note_content_renderer.js";
|
import noteContentRenderer from "./note_content_renderer.js";
|
||||||
@ -44,7 +44,7 @@ async function mouseEnterHandler() {
|
|||||||
|
|
||||||
const noteId = treeService.getNoteIdFromNotePath(notePath);
|
const noteId = treeService.getNoteIdFromNotePath(notePath);
|
||||||
|
|
||||||
const note = await treeCache.getNote(noteId);
|
const note = await froca.getNote(noteId);
|
||||||
const content = await renderTooltip(note);
|
const content = await renderTooltip(note);
|
||||||
|
|
||||||
if (utils.isHtmlEmpty(content)) {
|
if (utils.isHtmlEmpty(content)) {
|
||||||
|
@ -4,7 +4,7 @@ import protectedSessionHolder from './protected_session_holder.js';
|
|||||||
import toastService from "./toast.js";
|
import toastService from "./toast.js";
|
||||||
import ws from "./ws.js";
|
import ws from "./ws.js";
|
||||||
import appContext from "./app_context.js";
|
import appContext from "./app_context.js";
|
||||||
import treeCache from "./tree_cache.js";
|
import froca from "./tree_cache.js";
|
||||||
|
|
||||||
let protectedSessionDeferred = null;
|
let protectedSessionDeferred = null;
|
||||||
|
|
||||||
@ -32,12 +32,12 @@ function enterProtectedSession() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function reloadData() {
|
async function reloadData() {
|
||||||
const allNoteIds = Object.keys(treeCache.notes);
|
const allNoteIds = Object.keys(froca.notes);
|
||||||
|
|
||||||
await treeCache.loadInitialTree();
|
await froca.loadInitialTree();
|
||||||
|
|
||||||
// make sure that all notes used in the application are loaded, including the ones not shown in the tree
|
// make sure that all notes used in the application are loaded, including the ones not shown in the tree
|
||||||
await treeCache.reloadNotes(allNoteIds, true);
|
await froca.reloadNotes(allNoteIds, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function setupProtectedSession(password) {
|
async function setupProtectedSession(password) {
|
||||||
@ -53,7 +53,7 @@ async function setupProtectedSession(password) {
|
|||||||
|
|
||||||
await reloadData();
|
await reloadData();
|
||||||
|
|
||||||
await appContext.triggerEvent('treeCacheReloaded');
|
await appContext.triggerEvent('frocaReloaded');
|
||||||
|
|
||||||
appContext.triggerEvent('protectedSessionStarted');
|
appContext.triggerEvent('protectedSessionStarted');
|
||||||
|
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
import FrontendScriptApi from './frontend_script_api.js';
|
import FrontendScriptApi from './frontend_script_api.js';
|
||||||
import utils from './utils.js';
|
import utils from './utils.js';
|
||||||
import treeCache from './tree_cache.js';
|
import froca from './tree_cache.js';
|
||||||
|
|
||||||
async function ScriptContext(startNoteId, allNoteIds, originEntity = null, $container = null) {
|
async function ScriptContext(startNoteId, allNoteIds, originEntity = null, $container = null) {
|
||||||
const modules = {};
|
const modules = {};
|
||||||
|
|
||||||
await treeCache.initializedPromise;
|
await froca.initializedPromise;
|
||||||
|
|
||||||
const startNote = await treeCache.getNote(startNoteId);
|
const startNote = await froca.getNote(startNoteId);
|
||||||
const allNotes = await treeCache.getNotes(allNoteIds);
|
const allNotes = await froca.getNotes(allNoteIds);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
modules: modules,
|
modules: modules,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import server from "./server.js";
|
import server from "./server.js";
|
||||||
import treeCache from "./tree_cache.js";
|
import froca from "./tree_cache.js";
|
||||||
|
|
||||||
async function searchForNoteIds(searchString) {
|
async function searchForNoteIds(searchString) {
|
||||||
return await server.get('search/' + encodeURIComponent(searchString));
|
return await server.get('search/' + encodeURIComponent(searchString));
|
||||||
@ -8,7 +8,7 @@ async function searchForNoteIds(searchString) {
|
|||||||
async function searchForNotes(searchString) {
|
async function searchForNotes(searchString) {
|
||||||
const noteIds = await searchForNoteIds(searchString);
|
const noteIds = await searchForNoteIds(searchString);
|
||||||
|
|
||||||
return await treeCache.getNotes(noteIds);
|
return await froca.getNotes(noteIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
@ -4,7 +4,7 @@ import utils from "./utils.js";
|
|||||||
import appContext from "./app_context.js";
|
import appContext from "./app_context.js";
|
||||||
import treeService from "./tree.js";
|
import treeService from "./tree.js";
|
||||||
import Component from "../widgets/component.js";
|
import Component from "../widgets/component.js";
|
||||||
import treeCache from "./tree_cache.js";
|
import froca from "./tree_cache.js";
|
||||||
import hoistedNoteService from "./hoisted_note.js";
|
import hoistedNoteService from "./hoisted_note.js";
|
||||||
|
|
||||||
class TabContext extends Component {
|
class TabContext extends Component {
|
||||||
@ -74,7 +74,7 @@ class TabContext extends Component {
|
|||||||
async getResolvedNotePath(inputNotePath) {
|
async getResolvedNotePath(inputNotePath) {
|
||||||
const noteId = treeService.getNoteIdFromNotePath(inputNotePath);
|
const noteId = treeService.getNoteIdFromNotePath(inputNotePath);
|
||||||
|
|
||||||
if ((await treeCache.getNote(noteId)).isDeleted) {
|
if ((await froca.getNote(noteId)).isDeleted) {
|
||||||
// no point in trying to resolve canonical notePath
|
// no point in trying to resolve canonical notePath
|
||||||
return inputNotePath;
|
return inputNotePath;
|
||||||
}
|
}
|
||||||
@ -95,18 +95,18 @@ class TabContext extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// if user choise to unhoist, cache was reloaded, but might not contain this note (since it's on unexpanded path)
|
// if user choise to unhoist, cache was reloaded, but might not contain this note (since it's on unexpanded path)
|
||||||
await treeCache.getNote(noteId);
|
await froca.getNote(noteId);
|
||||||
|
|
||||||
return resolvedNotePath;
|
return resolvedNotePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @property {NoteShort} */
|
/** @property {NoteShort} */
|
||||||
get note() {
|
get note() {
|
||||||
if (this.noteId && !(this.noteId in treeCache.notes)) {
|
if (this.noteId && !(this.noteId in froca.notes)) {
|
||||||
logError(`Cannot find tabContext's note id='${this.noteId}'`);
|
logError(`Cannot find tabContext's note id='${this.noteId}'`);
|
||||||
}
|
}
|
||||||
|
|
||||||
return treeCache.notes[this.noteId];
|
return froca.notes[this.noteId];
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @property {string[]} */
|
/** @property {string[]} */
|
||||||
@ -120,7 +120,7 @@ class TabContext extends Component {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return await treeCache.getNoteComplement(this.noteId);
|
return await froca.getNoteComplement(this.noteId);
|
||||||
}
|
}
|
||||||
|
|
||||||
isActive() {
|
isActive() {
|
||||||
@ -159,7 +159,7 @@ class TabContext extends Component {
|
|||||||
|
|
||||||
async entitiesReloadedEvent({loadResults}) {
|
async entitiesReloadedEvent({loadResults}) {
|
||||||
if (loadResults.isNoteReloaded(this.noteId)) {
|
if (loadResults.isNoteReloaded(this.noteId)) {
|
||||||
const note = await treeCache.getNote(this.noteId);
|
const note = await froca.getNote(this.noteId);
|
||||||
|
|
||||||
if (note.isDeleted) {
|
if (note.isDeleted) {
|
||||||
this.noteId = null;
|
this.noteId = null;
|
||||||
|
@ -2,7 +2,7 @@ import Component from "../widgets/component.js";
|
|||||||
import SpacedUpdate from "./spaced_update.js";
|
import SpacedUpdate from "./spaced_update.js";
|
||||||
import server from "./server.js";
|
import server from "./server.js";
|
||||||
import options from "./options.js";
|
import options from "./options.js";
|
||||||
import treeCache from "./tree_cache.js";
|
import froca from "./tree_cache.js";
|
||||||
import treeService from "./tree.js";
|
import treeService from "./tree.js";
|
||||||
import utils from "./utils.js";
|
import utils from "./utils.js";
|
||||||
import TabContext from "./tab_context.js";
|
import TabContext from "./tab_context.js";
|
||||||
@ -47,7 +47,7 @@ export default class TabManager extends Component {
|
|||||||
const notePath = window.location.hash.substr(1);
|
const notePath = window.location.hash.substr(1);
|
||||||
const noteId = treeService.getNoteIdFromNotePath(notePath);
|
const noteId = treeService.getNoteIdFromNotePath(notePath);
|
||||||
|
|
||||||
if (noteId && await treeCache.noteExists(noteId)) {
|
if (noteId && await froca.noteExists(noteId)) {
|
||||||
for (const tab of tabsToOpen) {
|
for (const tab of tabsToOpen) {
|
||||||
tab.active = false;
|
tab.active = false;
|
||||||
}
|
}
|
||||||
@ -72,7 +72,7 @@ export default class TabManager extends Component {
|
|||||||
for (const openTab of tabsToOpen) {
|
for (const openTab of tabsToOpen) {
|
||||||
const noteId = treeService.getNoteIdFromNotePath(openTab.notePath);
|
const noteId = treeService.getNoteIdFromNotePath(openTab.notePath);
|
||||||
|
|
||||||
if (await treeCache.noteExists(noteId)) {
|
if (await froca.noteExists(noteId)) {
|
||||||
// note doesn't exist so don't try to open tab for it
|
// note doesn't exist so don't try to open tab for it
|
||||||
filteredTabs.push(openTab);
|
filteredTabs.push(openTab);
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import ws from './ws.js';
|
import ws from './ws.js';
|
||||||
import utils from './utils.js';
|
import utils from './utils.js';
|
||||||
import server from './server.js';
|
import server from './server.js';
|
||||||
import treeCache from './tree_cache.js';
|
import froca from './tree_cache.js';
|
||||||
import hoistedNoteService from '../services/hoisted_note.js';
|
import hoistedNoteService from '../services/hoisted_note.js';
|
||||||
import appContext from "./app_context.js";
|
import appContext from "./app_context.js";
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ async function resolveNotePathToSegments(notePath, hoistedNoteId = 'root', logEr
|
|||||||
const parentNoteId = path[i++];
|
const parentNoteId = path[i++];
|
||||||
|
|
||||||
if (childNoteId !== null) {
|
if (childNoteId !== null) {
|
||||||
const child = await treeCache.getNote(childNoteId);
|
const child = await froca.getNote(childNoteId);
|
||||||
|
|
||||||
if (!child) {
|
if (!child) {
|
||||||
console.log(`Can't find note ${childNoteId}`);
|
console.log(`Can't find note ${childNoteId}`);
|
||||||
@ -70,7 +70,7 @@ async function resolveNotePathToSegments(notePath, hoistedNoteId = 'root', logEr
|
|||||||
|
|
||||||
if (!parents.some(p => p.noteId === parentNoteId)) {
|
if (!parents.some(p => p.noteId === parentNoteId)) {
|
||||||
if (logErrors) {
|
if (logErrors) {
|
||||||
const parent = treeCache.getNoteFromCache(parentNoteId);
|
const parent = froca.getNoteFromCache(parentNoteId);
|
||||||
|
|
||||||
console.log(utils.now(), `Did not find parent ${parentNoteId} (${parent ? parent.title : 'n/a'}) for child ${childNoteId} (${child.title}), available parents: ${parents.map(p => `${p.noteId} (${p.title})`)}`);
|
console.log(utils.now(), `Did not find parent ${parentNoteId} (${parent ? parent.title : 'n/a'}) for child ${childNoteId} (${child.title}), available parents: ${parents.map(p => `${p.noteId} (${p.title})`)}`);
|
||||||
}
|
}
|
||||||
@ -99,7 +99,7 @@ async function resolveNotePathToSegments(notePath, hoistedNoteId = 'root', logEr
|
|||||||
return effectivePathSegments;
|
return effectivePathSegments;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const note = await treeCache.getNote(getNoteIdFromNotePath(notePath));
|
const note = await froca.getNote(getNoteIdFromNotePath(notePath));
|
||||||
|
|
||||||
const someNotePathSegments = getSomeNotePathSegments(note, hoistedNoteId);
|
const someNotePathSegments = getSomeNotePathSegments(note, hoistedNoteId);
|
||||||
|
|
||||||
@ -158,7 +158,7 @@ function getNoteIdFromNotePath(notePath) {
|
|||||||
async function getBranchIdFromNotePath(notePath) {
|
async function getBranchIdFromNotePath(notePath) {
|
||||||
const {noteId, parentNoteId} = getNoteIdAndParentIdFromNotePath(notePath);
|
const {noteId, parentNoteId} = getNoteIdAndParentIdFromNotePath(notePath);
|
||||||
|
|
||||||
return await treeCache.getBranchId(parentNoteId, noteId);
|
return await froca.getBranchId(parentNoteId, noteId);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getNoteIdAndParentIdFromNotePath(notePath) {
|
function getNoteIdAndParentIdFromNotePath(notePath) {
|
||||||
@ -213,7 +213,7 @@ function getNotePath(node) {
|
|||||||
async function getNoteTitle(noteId, parentNoteId = null) {
|
async function getNoteTitle(noteId, parentNoteId = null) {
|
||||||
utils.assertArguments(noteId);
|
utils.assertArguments(noteId);
|
||||||
|
|
||||||
const note = await treeCache.getNote(noteId);
|
const note = await froca.getNote(noteId);
|
||||||
if (!note) {
|
if (!note) {
|
||||||
return "[not found]";
|
return "[not found]";
|
||||||
}
|
}
|
||||||
@ -224,7 +224,7 @@ async function getNoteTitle(noteId, parentNoteId = null) {
|
|||||||
const branchId = note.parentToBranch[parentNoteId];
|
const branchId = note.parentToBranch[parentNoteId];
|
||||||
|
|
||||||
if (branchId) {
|
if (branchId) {
|
||||||
const branch = treeCache.getBranch(branchId);
|
const branch = froca.getBranch(branchId);
|
||||||
|
|
||||||
if (branch && branch.prefix) {
|
if (branch && branch.prefix) {
|
||||||
title = `${branch.prefix} - ${title}`;
|
title = `${branch.prefix} - ${title}`;
|
||||||
|
@ -6,14 +6,14 @@ import appContext from "./app_context.js";
|
|||||||
import NoteComplement from "../entities/note_complement.js";
|
import NoteComplement from "../entities/note_complement.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TreeCache keeps a read only cache of note tree structure in frontend's memory.
|
* Froca keeps a read only cache of note tree structure in frontend's memory.
|
||||||
* - notes are loaded lazily when unknown noteId is requested
|
* - notes are loaded lazily when unknown noteId is requested
|
||||||
* - when note is loaded, all its parent and child branches are loaded as well. For a branch to be used, it's not must be loaded before
|
* - when note is loaded, all its parent and child branches are loaded as well. For a branch to be used, it's not must be loaded before
|
||||||
* - deleted notes are present in the cache as well, but they don't have any branches. As a result check for deleted branch is done by presence check - if the branch is not there even though the corresponding note has been loaded, we can infer it is deleted.
|
* - deleted notes are present in the cache as well, but they don't have any branches. As a result check for deleted branch is done by presence check - if the branch is not there even though the corresponding note has been loaded, we can infer it is deleted.
|
||||||
*
|
*
|
||||||
* Note and branch deletions are corner cases and usually not needed.
|
* Note and branch deletions are corner cases and usually not needed.
|
||||||
*/
|
*/
|
||||||
class TreeCache {
|
class Froca {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.initializedPromise = this.loadInitialTree();
|
this.initializedPromise = this.loadInitialTree();
|
||||||
}
|
}
|
||||||
@ -181,9 +181,9 @@ class TreeCache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// reset all the virtual branches from old search results
|
// reset all the virtual branches from old search results
|
||||||
if (note.noteId in treeCache.notes) {
|
if (note.noteId in froca.notes) {
|
||||||
treeCache.notes[note.noteId].children = [];
|
froca.notes[note.noteId].children = [];
|
||||||
treeCache.notes[note.noteId].childToBranch = {};
|
froca.notes[note.noteId].childToBranch = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
const branches = [...note.getBranches(), ...note.getChildBranches()];
|
const branches = [...note.getBranches(), ...note.getChildBranches()];
|
||||||
@ -204,7 +204,7 @@ class TreeCache {
|
|||||||
attributes: []
|
attributes: []
|
||||||
});
|
});
|
||||||
|
|
||||||
treeCache.notes[note.noteId].searchResultsLoaded = true;
|
froca.notes[note.noteId].searchResultsLoaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return {NoteShort[]} */
|
/** @return {NoteShort[]} */
|
||||||
@ -320,6 +320,6 @@ class TreeCache {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const treeCache = new TreeCache();
|
const froca = new Froca();
|
||||||
|
|
||||||
export default treeCache;
|
export default froca;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import treeService from './tree.js';
|
import treeService from './tree.js';
|
||||||
import treeCache from "./tree_cache.js";
|
import froca from "./tree_cache.js";
|
||||||
import clipboard from './clipboard.js';
|
import clipboard from './clipboard.js';
|
||||||
import noteCreateService from "./note_create.js";
|
import noteCreateService from "./note_create.js";
|
||||||
import contextMenu from "./context_menu.js";
|
import contextMenu from "./context_menu.js";
|
||||||
@ -36,11 +36,11 @@ class TreeContextMenu {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getMenuItems() {
|
async getMenuItems() {
|
||||||
const note = await treeCache.getNote(this.node.data.noteId);
|
const note = await froca.getNote(this.node.data.noteId);
|
||||||
const branch = treeCache.getBranch(this.node.data.branchId);
|
const branch = froca.getBranch(this.node.data.branchId);
|
||||||
const isNotRoot = note.noteId !== 'root';
|
const isNotRoot = note.noteId !== 'root';
|
||||||
const isHoisted = note.noteId === appContext.tabManager.getActiveTabContext().hoistedNoteId;
|
const isHoisted = note.noteId === appContext.tabManager.getActiveTabContext().hoistedNoteId;
|
||||||
const parentNote = isNotRoot ? await treeCache.getNote(branch.parentNoteId) : null;
|
const parentNote = isNotRoot ? await froca.getNote(branch.parentNoteId) : null;
|
||||||
|
|
||||||
// some actions don't support multi-note so they are disabled when notes are selected
|
// some actions don't support multi-note so they are disabled when notes are selected
|
||||||
// the only exception is when the only selected note is the one that was right-clicked, then
|
// the only exception is when the only selected note is the one that was right-clicked, then
|
||||||
|
@ -5,7 +5,7 @@ import LoadResults from "./load_results.js";
|
|||||||
import Branch from "../entities/branch.js";
|
import Branch from "../entities/branch.js";
|
||||||
import Attribute from "../entities/attribute.js";
|
import Attribute from "../entities/attribute.js";
|
||||||
import options from "./options.js";
|
import options from "./options.js";
|
||||||
import treeCache from "./tree_cache.js";
|
import froca from "./tree_cache.js";
|
||||||
import noteAttributeCache from "./note_attribute_cache.js";
|
import noteAttributeCache from "./note_attribute_cache.js";
|
||||||
|
|
||||||
const messageHandlers = [];
|
const messageHandlers = [];
|
||||||
@ -213,10 +213,10 @@ setTimeout(() => {
|
|||||||
}, 0);
|
}, 0);
|
||||||
|
|
||||||
async function processEntityChanges(entityChanges) {
|
async function processEntityChanges(entityChanges) {
|
||||||
const loadResults = new LoadResults(treeCache);
|
const loadResults = new LoadResults(froca);
|
||||||
|
|
||||||
for (const ec of entityChanges.filter(ec => ec.entityName === 'notes')) {
|
for (const ec of entityChanges.filter(ec => ec.entityName === 'notes')) {
|
||||||
const note = treeCache.notes[ec.entityId];
|
const note = froca.notes[ec.entityId];
|
||||||
|
|
||||||
if (note) {
|
if (note) {
|
||||||
note.update(ec.entity);
|
note.update(ec.entity);
|
||||||
@ -225,9 +225,9 @@ async function processEntityChanges(entityChanges) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (const ec of entityChanges.filter(ec => ec.entityName === 'branches')) {
|
for (const ec of entityChanges.filter(ec => ec.entityName === 'branches')) {
|
||||||
let branch = treeCache.branches[ec.entityId];
|
let branch = froca.branches[ec.entityId];
|
||||||
const childNote = treeCache.notes[ec.entity.noteId];
|
const childNote = froca.notes[ec.entity.noteId];
|
||||||
const parentNote = treeCache.notes[ec.entity.parentNoteId];
|
const parentNote = froca.notes[ec.entity.parentNoteId];
|
||||||
|
|
||||||
if (branch) {
|
if (branch) {
|
||||||
branch.update(ec.entity);
|
branch.update(ec.entity);
|
||||||
@ -256,8 +256,8 @@ async function processEntityChanges(entityChanges) {
|
|||||||
}
|
}
|
||||||
else if (!ec.entity.isDeleted) {
|
else if (!ec.entity.isDeleted) {
|
||||||
if (childNote || parentNote) {
|
if (childNote || parentNote) {
|
||||||
branch = new Branch(treeCache, ec.entity);
|
branch = new Branch(froca, ec.entity);
|
||||||
treeCache.branches[branch.branchId] = branch;
|
froca.branches[branch.branchId] = branch;
|
||||||
|
|
||||||
loadResults.addBranch(ec.entityId, ec.sourceId);
|
loadResults.addBranch(ec.entityId, ec.sourceId);
|
||||||
|
|
||||||
@ -276,7 +276,7 @@ async function processEntityChanges(entityChanges) {
|
|||||||
const parentNoteIdsToSort = new Set();
|
const parentNoteIdsToSort = new Set();
|
||||||
|
|
||||||
for (const branchId in ec.positions) {
|
for (const branchId in ec.positions) {
|
||||||
const branch = treeCache.branches[branchId];
|
const branch = froca.branches[branchId];
|
||||||
|
|
||||||
if (branch) {
|
if (branch) {
|
||||||
branch.notePosition = ec.positions[branchId];
|
branch.notePosition = ec.positions[branchId];
|
||||||
@ -286,7 +286,7 @@ async function processEntityChanges(entityChanges) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (const parentNoteId of parentNoteIdsToSort) {
|
for (const parentNoteId of parentNoteIdsToSort) {
|
||||||
const parentNote = treeCache.notes[parentNoteId];
|
const parentNote = froca.notes[parentNoteId];
|
||||||
|
|
||||||
if (parentNote) {
|
if (parentNote) {
|
||||||
parentNote.sortChildren();
|
parentNote.sortChildren();
|
||||||
@ -298,9 +298,9 @@ async function processEntityChanges(entityChanges) {
|
|||||||
|
|
||||||
// missing reloading the relation target note
|
// missing reloading the relation target note
|
||||||
for (const ec of entityChanges.filter(ec => ec.entityName === 'attributes')) {
|
for (const ec of entityChanges.filter(ec => ec.entityName === 'attributes')) {
|
||||||
let attribute = treeCache.attributes[ec.entityId];
|
let attribute = froca.attributes[ec.entityId];
|
||||||
const sourceNote = treeCache.notes[ec.entity.noteId];
|
const sourceNote = froca.notes[ec.entity.noteId];
|
||||||
const targetNote = ec.entity.type === 'relation' && treeCache.notes[ec.entity.value];
|
const targetNote = ec.entity.type === 'relation' && froca.notes[ec.entity.value];
|
||||||
|
|
||||||
if (attribute) {
|
if (attribute) {
|
||||||
attribute.update(ec.entity);
|
attribute.update(ec.entity);
|
||||||
@ -318,9 +318,9 @@ async function processEntityChanges(entityChanges) {
|
|||||||
}
|
}
|
||||||
else if (!ec.entity.isDeleted) {
|
else if (!ec.entity.isDeleted) {
|
||||||
if (sourceNote || targetNote) {
|
if (sourceNote || targetNote) {
|
||||||
attribute = new Attribute(treeCache, ec.entity);
|
attribute = new Attribute(froca, ec.entity);
|
||||||
|
|
||||||
treeCache.attributes[attribute.attributeId] = attribute;
|
froca.attributes[attribute.attributeId] = attribute;
|
||||||
|
|
||||||
loadResults.addAttribute(ec.entityId, ec.sourceId);
|
loadResults.addAttribute(ec.entityId, ec.sourceId);
|
||||||
|
|
||||||
@ -336,7 +336,7 @@ async function processEntityChanges(entityChanges) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (const ec of entityChanges.filter(ec => ec.entityName === 'note_contents')) {
|
for (const ec of entityChanges.filter(ec => ec.entityName === 'note_contents')) {
|
||||||
delete treeCache.noteComplementPromises[ec.entityId];
|
delete froca.noteComplementPromises[ec.entityId];
|
||||||
|
|
||||||
loadResults.addNoteContent(ec.entityId, ec.sourceId);
|
loadResults.addNoteContent(ec.entityId, ec.sourceId);
|
||||||
}
|
}
|
||||||
@ -358,20 +358,20 @@ async function processEntityChanges(entityChanges) {
|
|||||||
const missingNoteIds = [];
|
const missingNoteIds = [];
|
||||||
|
|
||||||
for (const {entityName, entity} of entityChanges) {
|
for (const {entityName, entity} of entityChanges) {
|
||||||
if (entityName === 'branches' && !(entity.parentNoteId in treeCache.notes)) {
|
if (entityName === 'branches' && !(entity.parentNoteId in froca.notes)) {
|
||||||
missingNoteIds.push(entity.parentNoteId);
|
missingNoteIds.push(entity.parentNoteId);
|
||||||
}
|
}
|
||||||
else if (entityName === 'attributes'
|
else if (entityName === 'attributes'
|
||||||
&& entity.type === 'relation'
|
&& entity.type === 'relation'
|
||||||
&& entity.name === 'template'
|
&& entity.name === 'template'
|
||||||
&& !(entity.value in treeCache.notes)) {
|
&& !(entity.value in froca.notes)) {
|
||||||
|
|
||||||
missingNoteIds.push(entity.value);
|
missingNoteIds.push(entity.value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (missingNoteIds.length > 0) {
|
if (missingNoteIds.length > 0) {
|
||||||
await treeCache.reloadNotes(missingNoteIds);
|
await froca.reloadNotes(missingNoteIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!loadResults.isEmpty()) {
|
if (!loadResults.isEmpty()) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import server from "../../services/server.js";
|
import server from "../../services/server.js";
|
||||||
import treeCache from "../../services/tree_cache.js";
|
import froca from "../../services/tree_cache.js";
|
||||||
import treeService from "../../services/tree.js";
|
import treeService from "../../services/tree.js";
|
||||||
import linkService from "../../services/link.js";
|
import linkService from "../../services/link.js";
|
||||||
import attributeAutocompleteService from "../../services/attribute_autocomplete.js";
|
import attributeAutocompleteService from "../../services/attribute_autocomplete.js";
|
||||||
@ -429,7 +429,7 @@ export default class AttributeDetailWidget extends TabAwareWidget {
|
|||||||
.setSelectedNotePath("");
|
.setSelectedNotePath("");
|
||||||
|
|
||||||
if (attribute.value) {
|
if (attribute.value) {
|
||||||
const targetNote = await treeCache.getNote(attribute.value);
|
const targetNote = await froca.getNote(attribute.value);
|
||||||
|
|
||||||
if (targetNote) {
|
if (targetNote) {
|
||||||
this.$inputTargetNote
|
this.$inputTargetNote
|
||||||
@ -542,7 +542,7 @@ export default class AttributeDetailWidget extends TabAwareWidget {
|
|||||||
this.$relatedNotesList.empty();
|
this.$relatedNotesList.empty();
|
||||||
|
|
||||||
const displayedResults = results.length <= DISPLAYED_NOTES ? results : results.slice(0, DISPLAYED_NOTES);
|
const displayedResults = results.length <= DISPLAYED_NOTES ? results : results.slice(0, DISPLAYED_NOTES);
|
||||||
const displayedNotes = await treeCache.getNotes(displayedResults.map(res => res.noteId));
|
const displayedNotes = await froca.getNotes(displayedResults.map(res => res.noteId));
|
||||||
|
|
||||||
for (const note of displayedNotes) {
|
for (const note of displayedNotes) {
|
||||||
const notePath = treeService.getSomeNotePath(note);
|
const notePath = treeService.getSomeNotePath(note);
|
||||||
|
@ -4,7 +4,7 @@ import server from "../../services/server.js";
|
|||||||
import contextMenuService from "../../services/context_menu.js";
|
import contextMenuService from "../../services/context_menu.js";
|
||||||
import attributesParser from "../../services/attribute_parser.js";
|
import attributesParser from "../../services/attribute_parser.js";
|
||||||
import libraryLoader from "../../services/library_loader.js";
|
import libraryLoader from "../../services/library_loader.js";
|
||||||
import treeCache from "../../services/tree_cache.js";
|
import froca from "../../services/tree_cache.js";
|
||||||
import attributeRenderer from "../../services/attribute_renderer.js";
|
import attributeRenderer from "../../services/attribute_renderer.js";
|
||||||
import noteCreateService from "../../services/note_create.js";
|
import noteCreateService from "../../services/note_create.js";
|
||||||
import treeService from "../../services/tree.js";
|
import treeService from "../../services/tree.js";
|
||||||
@ -446,7 +446,7 @@ export default class AttributeEditorWidget extends TabAwareWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async loadReferenceLinkTitle(noteId, $el) {
|
async loadReferenceLinkTitle(noteId, $el) {
|
||||||
const note = await treeCache.getNote(noteId, true);
|
const note = await froca.getNote(noteId, true);
|
||||||
|
|
||||||
let title;
|
let title;
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import CollapsibleWidget from "../collapsible_widget.js";
|
import CollapsibleWidget from "../collapsible_widget.js";
|
||||||
import linkService from "../../services/link.js";
|
import linkService from "../../services/link.js";
|
||||||
import server from "../../services/server.js";
|
import server from "../../services/server.js";
|
||||||
import treeCache from "../../services/tree_cache.js";
|
import froca from "../../services/tree_cache.js";
|
||||||
|
|
||||||
const TPL = `
|
const TPL = `
|
||||||
<div class="edited-notes-widget">
|
<div class="edited-notes-widget">
|
||||||
@ -54,7 +54,7 @@ export default class EditedNotesWidget extends CollapsibleWidget {
|
|||||||
|
|
||||||
const noteIds = editedNotes.flatMap(n => n.noteId);
|
const noteIds = editedNotes.flatMap(n => n.noteId);
|
||||||
|
|
||||||
await treeCache.getNotes(noteIds, true); // preload all at once
|
await froca.getNotes(noteIds, true); // preload all at once
|
||||||
|
|
||||||
for (const editedNote of editedNotes) {
|
for (const editedNote of editedNotes) {
|
||||||
const $item = $('<div class="edited-note-line">');
|
const $item = $('<div class="edited-note-line">');
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import CollapsibleWidget from "../collapsible_widget.js";
|
import CollapsibleWidget from "../collapsible_widget.js";
|
||||||
import treeCache from "../../services/tree_cache.js";
|
import froca from "../../services/tree_cache.js";
|
||||||
|
|
||||||
let linkMapContainerIdCtr = 1;
|
let linkMapContainerIdCtr = 1;
|
||||||
|
|
||||||
@ -105,7 +105,7 @@ export default class LinkMapWidget extends CollapsibleWidget {
|
|||||||
const $linkMapContainer = this.$body.find('.link-map-container');
|
const $linkMapContainer = this.$body.find('.link-map-container');
|
||||||
|
|
||||||
for (const noteId of changedNoteIds) {
|
for (const noteId of changedNoteIds) {
|
||||||
const note = treeCache.notes[noteId];
|
const note = froca.notes[noteId];
|
||||||
|
|
||||||
if (note) {
|
if (note) {
|
||||||
$linkMapContainer.find(`a[data-note-path="${noteId}"]`).text(note.title);
|
$linkMapContainer.find(`a[data-note-path="${noteId}"]`).text(note.title);
|
||||||
|
@ -2,7 +2,7 @@ import hoistedNoteService from "../services/hoisted_note.js";
|
|||||||
import treeService from "../services/tree.js";
|
import treeService from "../services/tree.js";
|
||||||
import utils from "../services/utils.js";
|
import utils from "../services/utils.js";
|
||||||
import contextMenu from "../services/context_menu.js";
|
import contextMenu from "../services/context_menu.js";
|
||||||
import treeCache from "../services/tree_cache.js";
|
import froca from "../services/tree_cache.js";
|
||||||
import branchService from "../services/branches.js";
|
import branchService from "../services/branches.js";
|
||||||
import ws from "../services/ws.js";
|
import ws from "../services/ws.js";
|
||||||
import TabAwareWidget from "./tab_aware_widget.js";
|
import TabAwareWidget from "./tab_aware_widget.js";
|
||||||
@ -492,8 +492,8 @@ export default class NoteTreeWidget extends TabAwareWidget {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
data.result = treeCache.loadSearchNote(noteId).then(() => {
|
data.result = froca.loadSearchNote(noteId).then(() => {
|
||||||
const note = treeCache.getNoteFromCache(noteId);
|
const note = froca.getNoteFromCache(noteId);
|
||||||
|
|
||||||
let childNoteIds = note.getChildNoteIds();
|
let childNoteIds = note.getChildNoteIds();
|
||||||
|
|
||||||
@ -501,15 +501,15 @@ export default class NoteTreeWidget extends TabAwareWidget {
|
|||||||
childNoteIds = childNoteIds.slice(0, MAX_SEARCH_RESULTS_IN_TREE);
|
childNoteIds = childNoteIds.slice(0, MAX_SEARCH_RESULTS_IN_TREE);
|
||||||
}
|
}
|
||||||
|
|
||||||
return treeCache.getNotes(childNoteIds);
|
return froca.getNotes(childNoteIds);
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
const note = treeCache.getNoteFromCache(noteId);
|
const note = froca.getNoteFromCache(noteId);
|
||||||
|
|
||||||
return this.prepareChildren(note);
|
return this.prepareChildren(note);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
data.result = treeCache.loadSubTree(noteId).then(note => this.prepareChildren(note));
|
data.result = froca.loadSubTree(noteId).then(note => this.prepareChildren(note));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
clones: {
|
clones: {
|
||||||
@ -524,7 +524,7 @@ export default class NoteTreeWidget extends TabAwareWidget {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const note = await treeCache.getNote(node.data.noteId);
|
const note = await froca.getNote(node.data.noteId);
|
||||||
const activeTabContext = appContext.tabManager.getActiveTabContext();
|
const activeTabContext = appContext.tabManager.getActiveTabContext();
|
||||||
|
|
||||||
const $span = $(node.span);
|
const $span = $(node.span);
|
||||||
@ -600,7 +600,7 @@ export default class NoteTreeWidget extends TabAwareWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
prepareRootNode() {
|
prepareRootNode() {
|
||||||
return this.prepareNode(treeCache.getBranch('root'));
|
return this.prepareNode(froca.getBranch('root'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -637,8 +637,8 @@ export default class NoteTreeWidget extends TabAwareWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateNode(node) {
|
updateNode(node) {
|
||||||
const note = treeCache.getNoteFromCache(node.data.noteId);
|
const note = froca.getNoteFromCache(node.data.noteId);
|
||||||
const branch = treeCache.getBranch(node.data.branchId);
|
const branch = froca.getBranch(node.data.branchId);
|
||||||
|
|
||||||
if (!note) {
|
if (!note) {
|
||||||
console.log(`Node update not possible because note ${node.data.noteId} was not found.`);
|
console.log(`Node update not possible because note ${node.data.noteId} was not found.`);
|
||||||
@ -765,7 +765,7 @@ export default class NoteTreeWidget extends TabAwareWidget {
|
|||||||
|
|
||||||
const {branchIds} = await server.put(`branches/${node.data.branchId}/expanded-subtree/${isExpanded ? 1 : 0}`);
|
const {branchIds} = await server.put(`branches/${node.data.branchId}/expanded-subtree/${isExpanded ? 1 : 0}`);
|
||||||
|
|
||||||
treeCache.getBranches(branchIds, true)
|
froca.getBranches(branchIds, true)
|
||||||
.forEach(branch => branch.isExpanded = !!isExpanded);
|
.forEach(branch => branch.isExpanded = !!isExpanded);
|
||||||
|
|
||||||
await this.batchUpdate(async () => {
|
await this.batchUpdate(async () => {
|
||||||
@ -854,7 +854,7 @@ export default class NoteTreeWidget extends TabAwareWidget {
|
|||||||
|
|
||||||
// although previous line should set the expanded status, it seems to happen asynchronously
|
// although previous line should set the expanded status, it seems to happen asynchronously
|
||||||
// so we need to make sure it is set properly before calling updateNode which uses this flag
|
// so we need to make sure it is set properly before calling updateNode which uses this flag
|
||||||
const branch = treeCache.getBranch(parentNode.data.branchId);
|
const branch = froca.getBranch(parentNode.data.branchId);
|
||||||
branch.isExpanded = true;
|
branch.isExpanded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -873,7 +873,7 @@ export default class NoteTreeWidget extends TabAwareWidget {
|
|||||||
// these are real notes with real notePath, user can display them in a detail
|
// these are real notes with real notePath, user can display them in a detail
|
||||||
// but they don't have a node in the tree
|
// but they don't have a node in the tree
|
||||||
|
|
||||||
const childNote = await treeCache.getNote(childNoteId);
|
const childNote = await froca.getNote(childNoteId);
|
||||||
|
|
||||||
if (!childNote || childNote.type !== 'image') {
|
if (!childNote || childNote.type !== 'image') {
|
||||||
ws.logError(`Can't find node for child node of noteId=${childNoteId} for parent of noteId=${parentNode.data.noteId} and hoistedNoteId=${hoistedNoteService.getHoistedNoteId()}, requested path is ${notePath}`);
|
ws.logError(`Can't find node for child node of noteId=${childNoteId} for parent of noteId=${parentNode.data.noteId} and hoistedNoteId=${hoistedNoteService.getHoistedNoteId()}, requested path is ${notePath}`);
|
||||||
@ -905,7 +905,7 @@ export default class NoteTreeWidget extends TabAwareWidget {
|
|||||||
getNodesByBranchId(branchId) {
|
getNodesByBranchId(branchId) {
|
||||||
utils.assertArguments(branchId);
|
utils.assertArguments(branchId);
|
||||||
|
|
||||||
const branch = treeCache.getBranch(branchId);
|
const branch = froca.getBranch(branchId);
|
||||||
|
|
||||||
return this.getNodesByNoteId(branch.noteId).filter(node => node.data.branchId === branchId);
|
return this.getNodesByNoteId(branch.noteId).filter(node => node.data.branchId === branchId);
|
||||||
}
|
}
|
||||||
@ -1044,7 +1044,7 @@ export default class NoteTreeWidget extends TabAwareWidget {
|
|||||||
noteIdsToReload.add(attr.noteId);
|
noteIdsToReload.add(attr.noteId);
|
||||||
}
|
}
|
||||||
else if (attr.type === 'relation' && attr.name === 'imageLink') {
|
else if (attr.type === 'relation' && attr.name === 'imageLink') {
|
||||||
const note = treeCache.getNoteFromCache(attr.noteId);
|
const note = froca.getNoteFromCache(attr.noteId);
|
||||||
|
|
||||||
if (note && note.getChildNoteIds().includes(attr.value)) {
|
if (note && note.getChildNoteIds().includes(attr.value)) {
|
||||||
// there's new/deleted imageLink betwen note and its image child - which can show/hide
|
// there's new/deleted imageLink betwen note and its image child - which can show/hide
|
||||||
@ -1088,9 +1088,9 @@ export default class NoteTreeWidget extends TabAwareWidget {
|
|||||||
|
|
||||||
if (!found) {
|
if (!found) {
|
||||||
// make sure it's loaded
|
// make sure it's loaded
|
||||||
await treeCache.getNote(branch.noteId);
|
await froca.getNote(branch.noteId);
|
||||||
|
|
||||||
// we're forcing lazy since it's not clear if the whole required subtree is in tree cache
|
// we're forcing lazy since it's not clear if the whole required subtree is in froca
|
||||||
parentNode.addChildren([this.prepareNode(branch, true)]);
|
parentNode.addChildren([this.prepareNode(branch, true)]);
|
||||||
|
|
||||||
this.sortChildren(parentNode);
|
this.sortChildren(parentNode);
|
||||||
@ -1180,8 +1180,8 @@ export default class NoteTreeWidget extends TabAwareWidget {
|
|||||||
|
|
||||||
sortChildren(node) {
|
sortChildren(node) {
|
||||||
node.sortChildren((nodeA, nodeB) => {
|
node.sortChildren((nodeA, nodeB) => {
|
||||||
const branchA = treeCache.branches[nodeA.data.branchId];
|
const branchA = froca.branches[nodeA.data.branchId];
|
||||||
const branchB = treeCache.branches[nodeB.data.branchId];
|
const branchB = froca.branches[nodeB.data.branchId];
|
||||||
|
|
||||||
if (!branchA || !branchB) {
|
if (!branchA || !branchB) {
|
||||||
return 0;
|
return 0;
|
||||||
@ -1194,7 +1194,7 @@ export default class NoteTreeWidget extends TabAwareWidget {
|
|||||||
setExpanded(branchId, isExpanded) {
|
setExpanded(branchId, isExpanded) {
|
||||||
utils.assertArguments(branchId);
|
utils.assertArguments(branchId);
|
||||||
|
|
||||||
const branch = treeCache.getBranch(branchId, true);
|
const branch = froca.getBranch(branchId, true);
|
||||||
|
|
||||||
if (!branch) {
|
if (!branch) {
|
||||||
if (branchId && branchId.startsWith('virt')) {
|
if (branchId && branchId.startsWith('virt')) {
|
||||||
@ -1254,7 +1254,7 @@ export default class NoteTreeWidget extends TabAwareWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
treeCacheReloadedEvent() {
|
frocaReloadedEvent() {
|
||||||
this.reloadTreeFromCache();
|
this.reloadTreeFromCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1304,7 +1304,7 @@ export default class NoteTreeWidget extends TabAwareWidget {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const parentNote = treeCache.getNoteFromCache(node.getParent().data.noteId);
|
const parentNote = froca.getNoteFromCache(node.getParent().data.noteId);
|
||||||
|
|
||||||
if (parentNote && parentNote.hasLabel('sorted')) {
|
if (parentNote && parentNote.hasLabel('sorted')) {
|
||||||
return false;
|
return false;
|
||||||
@ -1469,13 +1469,13 @@ export default class NoteTreeWidget extends TabAwareWidget {
|
|||||||
const nodesToDuplicate = this.getSelectedOrActiveNodes(node);
|
const nodesToDuplicate = this.getSelectedOrActiveNodes(node);
|
||||||
|
|
||||||
for (const nodeToDuplicate of nodesToDuplicate) {
|
for (const nodeToDuplicate of nodesToDuplicate) {
|
||||||
const note = treeCache.getNoteFromCache(nodeToDuplicate.data.noteId);
|
const note = froca.getNoteFromCache(nodeToDuplicate.data.noteId);
|
||||||
|
|
||||||
if (note.isProtected && !protectedSessionHolder.isProtectedSessionAvailable()) {
|
if (note.isProtected && !protectedSessionHolder.isProtectedSessionAvailable()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const branch = treeCache.getBranch(nodeToDuplicate.data.branchId);
|
const branch = froca.getBranch(nodeToDuplicate.data.branchId);
|
||||||
|
|
||||||
noteCreateService.duplicateSubtree(nodeToDuplicate.data.noteId, branch.parentNoteId);
|
noteCreateService.duplicateSubtree(nodeToDuplicate.data.noteId, branch.parentNoteId);
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ import BasicWidget from "./basic_widget.js";
|
|||||||
import server from "../services/server.js";
|
import server from "../services/server.js";
|
||||||
import linkService from "../services/link.js";
|
import linkService from "../services/link.js";
|
||||||
import dateNotesService from "../services/date_notes.js";
|
import dateNotesService from "../services/date_notes.js";
|
||||||
import treeCache from "../services/tree_cache.js";
|
import froca from "../services/tree_cache.js";
|
||||||
import utils from "../services/utils.js";
|
import utils from "../services/utils.js";
|
||||||
import appContext from "../services/app_context.js";
|
import appContext from "../services/app_context.js";
|
||||||
|
|
||||||
@ -90,7 +90,7 @@ export default class QuickSearchWidget extends BasicWidget {
|
|||||||
this.$dropdownMenu.append('<span class="dropdown-item disabled">No results found</span>');
|
this.$dropdownMenu.append('<span class="dropdown-item disabled">No results found</span>');
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const note of await treeCache.getNotes(displayedNoteIds)) {
|
for (const note of await froca.getNotes(displayedNoteIds)) {
|
||||||
const $link = await linkService.createNoteLink(note.noteId, {showNotePath: true});
|
const $link = await linkService.createNoteLink(note.noteId, {showNotePath: true});
|
||||||
$link.addClass('dropdown-item');
|
$link.addClass('dropdown-item');
|
||||||
$link.attr("tabIndex", "0");
|
$link.attr("tabIndex", "0");
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import linkService from "../services/link.js";
|
import linkService from "../services/link.js";
|
||||||
import server from "../services/server.js";
|
import server from "../services/server.js";
|
||||||
import treeCache from "../services/tree_cache.js";
|
import froca from "../services/tree_cache.js";
|
||||||
import TabAwareWidget from "./tab_aware_widget.js";
|
import TabAwareWidget from "./tab_aware_widget.js";
|
||||||
import options from "../services/options.js";
|
import options from "../services/options.js";
|
||||||
|
|
||||||
@ -109,12 +109,12 @@ export default class SimilarNotesWidget extends TabAwareWidget {
|
|||||||
|
|
||||||
const noteIds = similarNotes.flatMap(note => note.notePath);
|
const noteIds = similarNotes.flatMap(note => note.notePath);
|
||||||
|
|
||||||
await treeCache.getNotes(noteIds, true); // preload all at once
|
await froca.getNotes(noteIds, true); // preload all at once
|
||||||
|
|
||||||
const $list = $('<div>');
|
const $list = $('<div>');
|
||||||
|
|
||||||
for (const similarNote of similarNotes) {
|
for (const similarNote of similarNotes) {
|
||||||
const note = await treeCache.getNote(similarNote.noteId, true);
|
const note = await froca.getNote(similarNote.noteId, true);
|
||||||
|
|
||||||
if (!note) {
|
if (!note) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -92,7 +92,7 @@ export default class TabAwareWidget extends BasicWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async treeCacheReloadedEvent() {
|
async frocaReloadedEvent() {
|
||||||
await this.refresh();
|
await this.refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ import contextMenu from "../services/context_menu.js";
|
|||||||
import utils from "../services/utils.js";
|
import utils from "../services/utils.js";
|
||||||
import keyboardActionService from "../services/keyboard_actions.js";
|
import keyboardActionService from "../services/keyboard_actions.js";
|
||||||
import appContext from "../services/app_context.js";
|
import appContext from "../services/app_context.js";
|
||||||
import treeCache from "../services/tree_cache.js";
|
import froca from "../services/tree_cache.js";
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Draggabilly v2.3.0
|
* Draggabilly v2.3.0
|
||||||
@ -635,7 +635,7 @@ export default class TabRowWidget extends BasicWidget {
|
|||||||
const tabContext = appContext.tabManager.getTabContextById(this.getTabId($tab));
|
const tabContext = appContext.tabManager.getTabContextById(this.getTabId($tab));
|
||||||
|
|
||||||
if (tabContext) {
|
if (tabContext) {
|
||||||
const hoistedNote = treeCache.getNoteFromCache(tabContext.hoistedNoteId);
|
const hoistedNote = froca.getNoteFromCache(tabContext.hoistedNoteId);
|
||||||
|
|
||||||
if (hoistedNote) {
|
if (hoistedNote) {
|
||||||
$tab.find('.note-tab-icon')
|
$tab.find('.note-tab-icon')
|
||||||
@ -680,7 +680,7 @@ export default class TabRowWidget extends BasicWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
treeCacheReloadedEvent() {
|
frocaReloadedEvent() {
|
||||||
for (const tabContext of appContext.tabManager.tabContexts) {
|
for (const tabContext of appContext.tabManager.tabContexts) {
|
||||||
const $tab = this.getTabById(tabContext.tabId);
|
const $tab = this.getTabById(tabContext.tabId);
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import server from "../../services/server.js";
|
import server from "../../services/server.js";
|
||||||
import TabAwareWidget from "../tab_aware_widget.js";
|
import TabAwareWidget from "../tab_aware_widget.js";
|
||||||
import treeCache from "../../services/tree_cache.js";
|
import froca from "../../services/tree_cache.js";
|
||||||
import ws from "../../services/ws.js";
|
import ws from "../../services/ws.js";
|
||||||
import toastService from "../../services/toast.js";
|
import toastService from "../../services/toast.js";
|
||||||
|
|
||||||
@ -265,7 +265,7 @@ export default class SearchDefinitionWidget extends TabAwareWidget {
|
|||||||
|
|
||||||
async refreshResultsCommand() {
|
async refreshResultsCommand() {
|
||||||
try {
|
try {
|
||||||
await treeCache.loadSearchNote(this.noteId);
|
await froca.loadSearchNote(this.noteId);
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
toastService.showError(e.message);
|
toastService.showError(e.message);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import TypeWidget from "./type_widget.js";
|
import TypeWidget from "./type_widget.js";
|
||||||
import appContext from "../../services/app_context.js";
|
import appContext from "../../services/app_context.js";
|
||||||
import treeCache from "../../services/tree_cache.js";
|
import froca from "../../services/tree_cache.js";
|
||||||
import linkService from "../../services/link.js";
|
import linkService from "../../services/link.js";
|
||||||
import noteContentRenderer from "../../services/note_content_renderer.js";
|
import noteContentRenderer from "../../services/note_content_renderer.js";
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ export default class AbstractTextTypeWidget extends TypeWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async loadIncludedNote(noteId, $el) {
|
async loadIncludedNote(noteId, $el) {
|
||||||
const note = await treeCache.getNote(noteId);
|
const note = await froca.getNote(noteId);
|
||||||
|
|
||||||
if (note) {
|
if (note) {
|
||||||
const $link = await linkService.createNoteLink(note.noteId, {
|
const $link = await linkService.createNoteLink(note.noteId, {
|
||||||
|
@ -3,7 +3,7 @@ import noteAutocompleteService from '../../services/note_autocomplete.js';
|
|||||||
import mimeTypesService from '../../services/mime_types.js';
|
import mimeTypesService from '../../services/mime_types.js';
|
||||||
import utils from "../../services/utils.js";
|
import utils from "../../services/utils.js";
|
||||||
import keyboardActionService from "../../services/keyboard_actions.js";
|
import keyboardActionService from "../../services/keyboard_actions.js";
|
||||||
import treeCache from "../../services/tree_cache.js";
|
import froca from "../../services/tree_cache.js";
|
||||||
import treeService from "../../services/tree.js";
|
import treeService from "../../services/tree.js";
|
||||||
import noteCreateService from "../../services/note_create.js";
|
import noteCreateService from "../../services/note_create.js";
|
||||||
import AbstractTextTypeWidget from "./abstract_text_type_widget.js";
|
import AbstractTextTypeWidget from "./abstract_text_type_widget.js";
|
||||||
@ -129,7 +129,7 @@ export default class EditableTextTypeWidget extends AbstractTextTypeWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async doRefresh(note) {
|
async doRefresh(note) {
|
||||||
const noteComplement = await treeCache.getNoteComplement(note.noteId);
|
const noteComplement = await froca.getNoteComplement(note.noteId);
|
||||||
|
|
||||||
await this.spacedUpdate.allowUpdateWithoutChange(() => {
|
await this.spacedUpdate.allowUpdateWithoutChange(() => {
|
||||||
this.textEditor.setData(noteComplement.content || "");
|
this.textEditor.setData(noteComplement.content || "");
|
||||||
@ -265,7 +265,7 @@ export default class EditableTextTypeWidget extends AbstractTextTypeWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async addImage(noteId) {
|
async addImage(noteId) {
|
||||||
const note = await treeCache.getNote(noteId);
|
const note = await froca.getNote(noteId);
|
||||||
|
|
||||||
this.textEditor.model.change( writer => {
|
this.textEditor.model.change( writer => {
|
||||||
const src = `api/images/${note.noteId}/${note.title}`;
|
const src = `api/images/${note.noteId}/${note.title}`;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import treeCache from "../../services/tree_cache.js";
|
import froca from "../../services/tree_cache.js";
|
||||||
import AbstractTextTypeWidget from "./abstract_text_type_widget.js";
|
import AbstractTextTypeWidget from "./abstract_text_type_widget.js";
|
||||||
import treeService from "../../services/tree.js";
|
import treeService from "../../services/tree.js";
|
||||||
import libraryLoader from "../../services/library_loader.js";
|
import libraryLoader from "../../services/library_loader.js";
|
||||||
@ -83,7 +83,7 @@ export default class ReadOnlyTextTypeWidget extends AbstractTextTypeWidget {
|
|||||||
// (see https://github.com/zadam/trilium/issues/1590 for example of such conflict)
|
// (see https://github.com/zadam/trilium/issues/1590 for example of such conflict)
|
||||||
await libraryLoader.requireLibrary(libraryLoader.CKEDITOR);
|
await libraryLoader.requireLibrary(libraryLoader.CKEDITOR);
|
||||||
|
|
||||||
const noteComplement = await treeCache.getNoteComplement(note.noteId);
|
const noteComplement = await froca.getNoteComplement(note.noteId);
|
||||||
|
|
||||||
this.$content.html(noteComplement.content);
|
this.$content.html(noteComplement.content);
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ import attributeAutocompleteService from "../../services/attribute_autocomplete.
|
|||||||
import TypeWidget from "./type_widget.js";
|
import TypeWidget from "./type_widget.js";
|
||||||
import appContext from "../../services/app_context.js";
|
import appContext from "../../services/app_context.js";
|
||||||
import utils from "../../services/utils.js";
|
import utils from "../../services/utils.js";
|
||||||
import treeCache from "../../services/tree_cache.js";
|
import froca from "../../services/tree_cache.js";
|
||||||
|
|
||||||
const uniDirectionalOverlays = [
|
const uniDirectionalOverlays = [
|
||||||
[ "Arrow", {
|
[ "Arrow", {
|
||||||
@ -532,7 +532,7 @@ export default class RelationMapTypeWidget extends TypeWidget {
|
|||||||
linkService.goToLink(e);
|
linkService.goToLink(e);
|
||||||
});
|
});
|
||||||
|
|
||||||
const note = await treeCache.getNote(noteId);
|
const note = await froca.getNote(noteId);
|
||||||
|
|
||||||
const $noteBox = $("<div>")
|
const $noteBox = $("<div>")
|
||||||
.addClass("note-box")
|
.addClass("note-box")
|
||||||
|
@ -235,7 +235,7 @@ class Note {
|
|||||||
this.ancestorCache = null;
|
this.ancestorCache = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
invalidateSubtreeCaches(path = []) {
|
invalidateSubfrocas(path = []) {
|
||||||
if (path.includes(this.noteId)) {
|
if (path.includes(this.noteId)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -247,7 +247,7 @@ class Note {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (const childNote of this.children) {
|
for (const childNote of this.children) {
|
||||||
childNote.invalidateSubtreeCaches(path);
|
childNote.invalidateSubfrocas(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const targetRelation of this.targetRelations) {
|
for (const targetRelation of this.targetRelations) {
|
||||||
@ -255,7 +255,7 @@ class Note {
|
|||||||
const note = targetRelation.note;
|
const note = targetRelation.note;
|
||||||
|
|
||||||
if (note) {
|
if (note) {
|
||||||
note.invalidateSubtreeCaches(path);
|
note.invalidateSubfrocas(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ eventService.subscribe([eventService.ENTITY_CHANGED, eventService.ENTITY_DELETED
|
|||||||
childNote.parentBranches = childNote.parentBranches.filter(branch => branch.branchId !== branchId);
|
childNote.parentBranches = childNote.parentBranches.filter(branch => branch.branchId !== branchId);
|
||||||
|
|
||||||
if (childNote.parents.length > 0) {
|
if (childNote.parents.length > 0) {
|
||||||
childNote.invalidateSubtreeCaches();
|
childNote.invalidateSubfrocas();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,7 +105,7 @@ eventService.subscribe([eventService.ENTITY_CHANGED, eventService.ENTITY_DELETED
|
|||||||
if (note && attr) {
|
if (note && attr) {
|
||||||
// first invalidate and only then remove the attribute (otherwise invalidation wouldn't be complete)
|
// first invalidate and only then remove the attribute (otherwise invalidation wouldn't be complete)
|
||||||
if (attr.isAffectingSubtree || note.isTemplate) {
|
if (attr.isAffectingSubtree || note.isTemplate) {
|
||||||
note.invalidateSubtreeCaches();
|
note.invalidateSubfrocas();
|
||||||
} else {
|
} else {
|
||||||
note.invalidateThisCache();
|
note.invalidateThisCache();
|
||||||
}
|
}
|
||||||
@ -147,7 +147,7 @@ eventService.subscribe([eventService.ENTITY_CHANGED, eventService.ENTITY_DELETED
|
|||||||
|
|
||||||
if (note) {
|
if (note) {
|
||||||
if (attr.isAffectingSubtree || note.isTemplate) {
|
if (attr.isAffectingSubtree || note.isTemplate) {
|
||||||
note.invalidateSubtreeCaches();
|
note.invalidateSubfrocas();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
note.invalidateThisCache();
|
note.invalidateThisCache();
|
||||||
|
@ -5,7 +5,7 @@ const log = require('./log');
|
|||||||
|
|
||||||
async function executeNote(note, apiParams) {
|
async function executeNote(note, apiParams) {
|
||||||
if (!note.isJavaScript() || note.getScriptEnv() !== 'backend' || !note.isContentAvailable) {
|
if (!note.isJavaScript() || note.getScriptEnv() !== 'backend' || !note.isContentAvailable) {
|
||||||
log.info(`Cannot execute note ${note.noteId}`);
|
log.info(`Cannot execute note ${note.noteId} "${note.title}", note must be of type "Code: JS frontend"`);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user