|
|
|
@ -1,5 +1,7 @@
|
|
|
|
"use strict";
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import Note from "./note.js";
|
|
|
|
|
|
|
|
|
|
|
|
class Branch {
|
|
|
|
class Branch {
|
|
|
|
constructor(noteCache, row) {
|
|
|
|
constructor(noteCache, row) {
|
|
|
|
/** @param {NoteCache} */
|
|
|
|
/** @param {NoteCache} */
|
|
|
|
@ -17,14 +19,9 @@ class Branch {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const childNote = this.noteCache.notes[this.noteId];
|
|
|
|
const childNote = this.childNote;
|
|
|
|
const parentNote = this.parentNote;
|
|
|
|
const parentNote = this.parentNote;
|
|
|
|
|
|
|
|
|
|
|
|
if (!childNote) {
|
|
|
|
|
|
|
|
console.log(`Cannot find child note ${this.noteId} of a branch ${this.branchId}`);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
childNote.parents.push(parentNote);
|
|
|
|
childNote.parents.push(parentNote);
|
|
|
|
childNote.parentBranches.push(this);
|
|
|
|
childNote.parentBranches.push(this);
|
|
|
|
|
|
|
|
|
|
|
|
@ -35,14 +32,23 @@ class Branch {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** @return {Note} */
|
|
|
|
/** @return {Note} */
|
|
|
|
get parentNote() {
|
|
|
|
get childNote() {
|
|
|
|
const note = this.noteCache.notes[this.parentNoteId];
|
|
|
|
if (!(this.noteId in this.noteCache.notes)) {
|
|
|
|
|
|
|
|
// entities can come out of order in sync, create skeleton which will be filled later
|
|
|
|
|
|
|
|
this.noteCache.notes[this.noteId] = new Note(this.noteCache, {noteId: this.noteId});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return this.noteCache.notes[this.noteId];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!note) {
|
|
|
|
/** @return {Note} */
|
|
|
|
console.log(`Cannot find note ${this.parentNoteId}`);
|
|
|
|
get parentNote() {
|
|
|
|
|
|
|
|
if (!(this.parentNoteId in this.noteCache.notes)) {
|
|
|
|
|
|
|
|
// entities can come out of order in sync, create skeleton which will be filled later
|
|
|
|
|
|
|
|
this.noteCache.notes[this.parentNoteId] = new Note(this.noteCache, {noteId: this.parentNoteId});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return note;
|
|
|
|
return this.noteCache.notes[this.parentNoteId];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|