server-ts: Port services/tree

This commit is contained in:
Elian Doran
2024-02-18 11:47:32 +02:00
parent d8d729342d
commit 0d4fb42731
10 changed files with 43 additions and 35 deletions

View File

@@ -267,17 +267,19 @@ class BBranch extends AbstractBeccaEntity<BBranch> {
};
}
createClone(parentNoteId: string, notePosition: number) {
createClone(parentNoteId: string, notePosition?: number) {
const existingBranch = this.becca.getBranchFromChildAndParent(this.noteId, parentNoteId);
if (existingBranch) {
existingBranch.notePosition = notePosition;
if (notePosition) {
existingBranch.notePosition = notePosition;
}
return existingBranch;
} else {
return new BBranch({
noteId: this.noteId,
parentNoteId: parentNoteId,
notePosition: notePosition,
notePosition: notePosition || null,
prefix: this.prefix,
isExpanded: this.isExpanded
});