mirror of
https://github.com/zadam/trilium.git
synced 2025-11-01 02:45:54 +01:00
split tree_cache and entities from note_tree
This commit is contained in:
45
src/public/javascripts/entities/note_short.js
Normal file
45
src/public/javascripts/entities/note_short.js
Normal file
@@ -0,0 +1,45 @@
|
||||
class NoteShort {
|
||||
constructor(treeCache, row) {
|
||||
this.treeCache = treeCache;
|
||||
this.noteId = row.noteId;
|
||||
this.title = row.title;
|
||||
this.isProtected = row.isProtected;
|
||||
this.type = row.type;
|
||||
this.mime = row.mime;
|
||||
this.hideInAutocomplete = row.hideInAutocomplete;
|
||||
}
|
||||
|
||||
async getBranches() {
|
||||
const branches = [];
|
||||
|
||||
for (const parent of this.treeCache.parents[this.noteId]) {
|
||||
branches.push(await this.treeCache.getBranchByChildParent(this.noteId, p.noteId));
|
||||
}
|
||||
|
||||
return branches;
|
||||
}
|
||||
|
||||
async getChildBranches() {
|
||||
const branches = [];
|
||||
|
||||
for (const child of this.treeCache.children[this.noteId]) {
|
||||
branches.push(await this.treeCache.getBranchByChildParent(child.noteId, this.noteId));
|
||||
}
|
||||
|
||||
return branches;
|
||||
}
|
||||
|
||||
async getParentNotes() {
|
||||
return this.treeCache.parents[this.noteId] || [];
|
||||
}
|
||||
|
||||
async getChildNotes() {
|
||||
return this.treeCache.children[this.noteId] || [];
|
||||
}
|
||||
|
||||
get toString() {
|
||||
return `Note(noteId=${this.noteId}, title=${this.title})`;
|
||||
}
|
||||
}
|
||||
|
||||
export default NoteShort;
|
||||
Reference in New Issue
Block a user