mirror of
https://github.com/zadam/trilium.git
synced 2025-10-27 16:26:31 +01:00
renamed treeCache into froca
This commit is contained in:
@@ -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.<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]] < 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 & 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<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' && attr.name === 'template')) {
|
||||
const templateNote = this.treeCache.notes[templateAttr.value];
|
||||
const templateNote = this.froca.notes[templateAttr.value];
|
||||
|
||||
if (templateNote && 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<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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user