Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
"use strict";
import AbstractShacaEntity from "./abstract_shaca_entity.js";
import type { SBranchRow } from "./rows.js";
import type SNote from "./snote.js";
class SBranch extends AbstractShacaEntity {
private branchId: string;
private noteId: string;
parentNoteId: string;
private prefix: string;
private isExpanded: boolean;
isHidden: boolean;
constructor([branchId, noteId, parentNoteId, prefix, isExpanded]: SBranchRow) {
super();
this.branchId = branchId;
this.noteId = noteId;
this.parentNoteId = parentNoteId;
this.prefix = prefix;
this.isExpanded = !!isExpanded;
this.isHidden = false;
const childNote = this.childNote;
const parentNote = this.parentNote;
if (!childNote.parents.includes(parentNote)) {
childNote.parents.push(parentNote);
}
childNote.parentBranches.push(this);
if (!parentNote.children.includes(childNote)) {
parentNote.children.push(childNote);
}
this.shaca.branches[this.branchId] = this;
this.shaca.childParentToBranch[`${this.noteId}-${this.parentNoteId}`] = this;
}
get childNote(): SNote {
return this.shaca.notes[this.noteId];
}
getNote() {
return this.childNote;
}
get parentNote(): SNote {
return this.shaca.notes[this.parentNoteId];
}
getParentNote() {
return this.parentNote;
}
getPojo() {
return {
branchId: this.branchId,
noteId: this.noteId,
parentNoteId: this.parentNoteId,
notePosition: this.parentNote.children.indexOf(this.childNote) * 10,
prefix: this.prefix,
isExpanded: this.isExpanded,
fromSearchNote: false
};
}
}
export default SBranch;