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
fix duplicating subtree with internal links, closes #3813
zadam839b172b9262
diff --git a/src/becca/entities/battribute.js b/src/becca/entities/battribute.jsindex ca14a90c0f..49b9fa258b 100644--- a/src/becca/entities/battribute.js+++ b/src/becca/entities/battribute.js@@ -96,7 +96,7 @@ class BAttribute extends AbstractBeccaEntity {}if (this.type === 'relation' && !(this.value in this.becca.notes)) {- throw new Error(`Cannot save relation '${this.name}' of note '${this.noteId}' since it target not existing note '${this.value}'.`);+ throw new Error(`Cannot save relation '${this.name}' of note '${this.noteId}' since it targets not existing note '${this.value}'.`);}}diff --git a/src/becca/entities/bnote.js b/src/becca/entities/bnote.jsindex 960b352343..2e9febadbe 100644--- a/src/becca/entities/bnote.js+++ b/src/becca/entities/bnote.js@@ -97,7 +97,7 @@ class BNote extends AbstractBeccaEntity {* @private */this.parents = [];/** @type {BNote[]}- * @private*/+ * @private */this.children = [];/** @type {BAttribute[]}* @private */@@ -107,11 +107,11 @@ class BNote extends AbstractBeccaEntity {* @private */this.__attributeCache = null;/** @type {BAttribute[]|null}- * @private*/+ * @private */this.inheritableAttributeCache = null;/** @type {BAttribute[]}- * @private*/+ * @private */this.targetRelations = [];this.becca.addNote(this.noteId, this);diff --git a/src/services/notes.js b/src/services/notes.jsindex 3da2f56fcd..d526372d27 100644--- a/src/services/notes.js+++ b/src/services/notes.js@@ -841,7 +841,7 @@ function duplicateSubtree(origNoteId, newParentNoteId) {throw new Error('Duplicating root is not possible');}- log.info(`Duplicating ${origNoteId} subtree into ${newParentNoteId}`);+ log.info(`Duplicating '${origNoteId}' subtree into '${newParentNoteId}'`);const origNote = becca.notes[origNoteId];// might be null if orig note is not in the target newParentNoteId@@ -919,7 +919,8 @@ function duplicateSubtreeInner(origNote, origBranch, newParentNoteId, noteIdMappattr.value = noteIdMapping[attr.value];}- attr.save();+ // the relation targets may not be created yet, the mapping is pre-generated+ attr.save({skipValidation: true});}for (const childBranch of origNote.getChildBranches()) {