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 overwriting / deleting auto links, closes #1406
zadam99f01b9ccfd6
diff --git a/src/entities/attribute.js b/src/entities/attribute.jsindex 857531ffea..b5aecf6e19 100644--- a/src/entities/attribute.js+++ b/src/entities/attribute.js@@ -34,6 +34,10 @@ class Attribute extends Entity {this.isInheritable = !!this.isInheritable;}+ isAutoLink() {+ return this.type === 'relation' && ['internalLink', 'imageLink', 'relationMapLink', 'includeNoteLink'].includes(this.name);+ }+/*** @returns {Note|null}*/diff --git a/src/routes/api/attributes.js b/src/routes/api/attributes.jsindex 345ecfae43..98360a36c7 100644--- a/src/routes/api/attributes.js+++ b/src/routes/api/attributes.js@@ -147,8 +147,10 @@ function updateNoteAttributes(req) {// all the remaining existing attributes are not defined anymore and should be deletedfor (const toDeleteAttr of existingAttrs) {- toDeleteAttr.isDeleted = true;- toDeleteAttr.save();+ if (!toDeleteAttr.isAutoLink()) {+ toDeleteAttr.isDeleted = true;+ toDeleteAttr.save();+ }}}