no need to create template relation if there is already one owned

This commit is contained in:
zadam
2022-06-19 14:06:00 +02:00
parent 5ed1631a35
commit 08e12e7349
29 changed files with 5268 additions and 829 deletions

View File

@@ -155,16 +155,19 @@ function createNewNote(params) {
scanForLinks(note);
copyChildAttributes(parentNote, note);
if (params.templateNoteId) {
if (!becca.getNote(params.templateNoteId)) {
throw new Error(`Template note '${params.templateNoteId}' does not exist.`);
}
note.addRelation('template', params.templateNoteId);
// could be already copied from the parent via `child:`, no need to have 2
if (!note.hasOwnedRelation('template', params.templateNoteId)) {
note.addRelation('template', params.templateNoteId);
}
}
copyChildAttributes(parentNote, note);
triggerNoteTitleChanged(note);
triggerChildNoteCreated(note, parentNote);