renamed treeCache into froca

This commit is contained in:
zadam
2021-04-16 22:57:37 +02:00
parent 4311834d75
commit af5b1021c7
63 changed files with 292 additions and 292 deletions

View File

@@ -28,11 +28,11 @@
<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
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>
@@ -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>
<td class="name"><code>treeCache</code></td>
<td class="name"><code>froca</code></td>
<td class="type">
<span class="param-type">TreeCache</span>
<span class="param-type">Froca</span>

View File

@@ -28,8 +28,8 @@
<article>
<pre class="prettyprint source linenums"><code>/** Represents mapping between note and parent note */
class Branch {
constructor(treeCache, row) {
this.treeCache = treeCache;
constructor(froca, row) {
this.froca = froca;
/** @param {string} primary key */
this.branchId = row.branchId;
/** @param {string} */
@@ -47,7 +47,7 @@ class Branch {
/** @returns {NoteShort} */
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 */

View File

@@ -29,8 +29,8 @@
<pre class="prettyprint source linenums"><code>import promotedAttributeDefinitionParser from '../services/promoted_attribute_definition_parser.js';
class Attribute {
constructor(treeCache, row) {
this.treeCache = treeCache;
constructor(froca, row) {
this.froca = froca;
this.update(row);
}
@@ -56,7 +56,7 @@ class Attribute {
/** @returns {NoteShort} */
getNote() {
return this.treeCache.notes[this.noteId];
return this.froca.notes[this.noteId];
}
get targetNoteId() { // alias
@@ -123,7 +123,7 @@ class Attribute {
get dto() {
const dto = Object.assign({}, this);
delete dto.treeCache;
delete dto.froca;
return dto;
}

View File

@@ -28,8 +28,8 @@
<article>
<pre class="prettyprint source linenums"><code>/** Represents mapping between note and parent note */
class Branch {
constructor(treeCache, row) {
this.treeCache = treeCache;
constructor(froca, row) {
this.froca = froca;
this.update(row);
}
@@ -55,17 +55,17 @@ class Branch {
/** @returns {NoteShort} */
async getNote() {
return this.treeCache.getNote(this.noteId);
return this.froca.getNote(this.noteId);
}
/** @returns {NoteShort} */
getNoteFromCache() {
return this.treeCache.getNoteFromCache(this.noteId);
return this.froca.getNoteFromCache(this.noteId);
}
/** @returns {NoteShort} */
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 */

View File

@@ -32,8 +32,8 @@
* Represents full note, specifically including note's content.
*/
class NoteFull extends NoteShort {
constructor(treeCache, row, noteShort) {
super(treeCache, row, []);
constructor(froca, row, noteShort) {
super(froca, row, []);
/** @param {string} */
this.content = row.content;

View File

@@ -30,7 +30,7 @@
import noteAttributeCache from "../services/note_attribute_cache.js";
import ws from "../services/ws.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 RELATION = 'relation';
@@ -48,15 +48,15 @@ const NOTE_TYPE_ICONS = {
/**
* 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 {
/**
* @param {TreeCache} treeCache
* @param {Froca} froca
* @param {Object.&lt;string, Object>} row
*/
constructor(treeCache, row) {
this.treeCache = treeCache;
constructor(froca, row) {
this.froca = froca;
/** @type {string[]} */
this.attributes = [];
@@ -121,7 +121,7 @@ class NoteShort {
const branchIdPos = {};
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]] &lt; branchIdPos[this.childToBranch[b]] ? -1 : 1);
@@ -133,7 +133,7 @@ class NoteShort {
}
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);
return note.content;
@@ -161,7 +161,7 @@ class NoteShort {
getBranches() {
const branchIds = Object.values(this.parentToBranch);
return this.treeCache.getBranches(branchIds);
return this.froca.getBranches(branchIds);
}
/** @returns {boolean} */
@@ -174,7 +174,7 @@ class NoteShort {
// don't use Object.values() to guarantee order
const branchIds = this.children.map(childNoteId => this.childToBranch[childNoteId]);
return this.treeCache.getBranches(branchIds);
return this.froca.getBranches(branchIds);
}
/** @returns {string[]} */
@@ -184,7 +184,7 @@ class NoteShort {
/** @returns {NoteShort[]} */
getParentNotes() {
return this.treeCache.getNotesFromCache(this.parents);
return this.froca.getNotesFromCache(this.parents);
}
// will sort the parents so that non-search &amp; non-archived are first and archived at the end
@@ -197,7 +197,7 @@ class NoteShort {
return 1;
}
const aNote = this.treeCache.getNoteFromCache([aNoteId]);
const aNote = this.froca.getNoteFromCache([aNoteId]);
if (aNote.hasLabel('archived')) {
return 1;
@@ -214,7 +214,7 @@ class NoteShort {
/** @returns {Promise&lt;NoteShort[]>} */
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) {
const attrs = this.attributes
.map(attributeId => this.treeCache.attributes[attributeId])
.map(attributeId => this.froca.attributes[attributeId])
.filter(Boolean); // filter out nulls;
return this.__filterAttrs(attrs, type, name);
@@ -260,7 +260,7 @@ class NoteShort {
}
for (const templateAttr of attrArrs.flat().filter(attr => attr.type === 'relation' &amp;&amp; attr.name === 'template')) {
const templateNote = this.treeCache.notes[templateAttr.value];
const templateNote = this.froca.notes[templateAttr.value];
if (templateNote &amp;&amp; templateNote.noteId !== this.noteId) {
attrArrs.push(templateNote.__getCachedAttributes(newPath));
@@ -329,8 +329,8 @@ class NoteShort {
const notePaths = this.getAllNotePaths().map(path => ({
notePath: path,
isInHoistedSubTree: path.includes(hoistedNotePath),
isArchived: path.find(noteId => treeCache.notes[noteId].hasLabel('archived')),
isSearch: path.find(noteId => treeCache.notes[noteId].type === 'search')
isArchived: path.find(noteId => froca.notes[noteId].hasLabel('archived')),
isSearch: path.find(noteId => froca.notes[noteId].type === 'search')
}));
notePaths.sort((a, b) => {
@@ -608,7 +608,7 @@ class NoteShort {
const targets = [];
for (const relation of relations) {
targets.push(await this.treeCache.getNote(relation.value));
targets.push(await this.froca.getNote(relation.value));
}
return targets;
@@ -620,7 +620,7 @@ class NoteShort {
getTemplateNotes() {
const relations = this.getRelations('template');
return relations.map(rel => this.treeCache.notes[rel.value]);
return relations.map(rel => this.froca.notes[rel.value]);
}
getPromotedDefinitionAttributes() {
@@ -681,7 +681,7 @@ class NoteShort {
*/
getTargetRelations() {
return this.targetRelations
.map(attributeId => this.treeCache.attributes[attributeId]);
.map(attributeId => this.froca.attributes[attributeId]);
}
/**
@@ -692,7 +692,7 @@ class NoteShort {
async getTargetRelationSourceNotes() {
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&lt;NoteComplement>}
*/
async getNoteComplement() {
return await this.treeCache.getNoteComplement(this.noteId);
return await this.froca.getNoteComplement(this.noteId);
}
get toString() {
@@ -710,7 +710,7 @@ class NoteShort {
get dto() {
const dto = Object.assign({}, this);
delete dto.treeCache;
delete dto.froca;
return dto;
}

View File

@@ -32,8 +32,8 @@
* Represents full note, specifically including note's content.
*/
class NoteFull extends NoteShort {
constructor(treeCache, row) {
super(treeCache, row);
constructor(froca, row) {
super(froca, row);
/** @param {string} */
this.content = row.content;

View File

@@ -27,12 +27,12 @@
<section>
<article>
<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.
*/
class NoteShort {
constructor(treeCache, row) {
this.treeCache = treeCache;
constructor(froca, row) {
this.froca = froca;
/** @param {string} */
this.noteId = row.noteId;
/** @param {string} */
@@ -55,48 +55,48 @@ class NoteShort {
/** @returns {Promise&lt;Array.&lt;Branch>>} */
async getBranches() {
const branchIds = this.treeCache.parents[this.noteId].map(
parentNoteId => this.treeCache.getBranchIdByChildParent(this.noteId, parentNoteId));
const branchIds = this.froca.parents[this.noteId].map(
parentNoteId => this.froca.getBranchIdByChildParent(this.noteId, parentNoteId));
return this.treeCache.getBranches(branchIds);
return this.froca.getBranches(branchIds);
}
/** @returns {boolean} */
hasChildren() {
return this.treeCache.children[this.noteId]
&amp;&amp; this.treeCache.children[this.noteId].length > 0;
return this.froca.children[this.noteId]
&amp;&amp; this.froca.children[this.noteId].length > 0;
}
/** @returns {Promise&lt;Array.&lt;Branch>>} */
async getChildBranches() {
if (!this.treeCache.children[this.noteId]) {
if (!this.froca.children[this.noteId]) {
return [];
}
const branchIds = this.treeCache.children[this.noteId].map(
childNoteId => this.treeCache.getBranchIdByChildParent(childNoteId, this.noteId));
const branchIds = this.froca.children[this.noteId].map(
childNoteId => this.froca.getBranchIdByChildParent(childNoteId, this.noteId));
return await this.treeCache.getBranches(branchIds);
return await this.froca.getBranches(branchIds);
}
/** @returns {Array.&lt;string>} */
getParentNoteIds() {
return this.treeCache.parents[this.noteId] || [];
return this.froca.parents[this.noteId] || [];
}
/** @returns {Promise&lt;Array.&lt;NoteShort>>} */
async getParentNotes() {
return await this.treeCache.getNotes(this.getParentNoteIds());
return await this.froca.getNotes(this.getParentNoteIds());
}
/** @returns {Array.&lt;string>} */
getChildNoteIds() {
return this.treeCache.children[this.noteId] || [];
return this.froca.children[this.noteId] || [];
}
/** @returns {Promise&lt;Array.&lt;NoteShort>>} */
async getChildNotes() {
return await this.treeCache.getNotes(this.getChildNoteIds());
return await this.froca.getNotes(this.getChildNoteIds());
}
get toString() {
@@ -105,7 +105,7 @@ class NoteShort {
get dto() {
const dto = Object.assign({}, this);
delete dto.treeCache;
delete dto.froca;
delete dto.archived;
return dto;

View File

@@ -30,7 +30,7 @@
import utils from './utils.js';
import toastService from './toast.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 protectedSessionService from './protected_session.js';
import dateNotesService from './date_notes.js';
@@ -251,7 +251,7 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain
* @param {string} noteId
* @return {Promise&lt;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.
@@ -263,7 +263,7 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain
* @param {boolean} [silentNotFoundError] - don't report error if the note is not found
* @return {Promise&lt;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.
@@ -271,7 +271,7 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain
* @param {string[]} noteIds
* @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