From 99f01b9ccfd6d3caa108ec74667d823ec8aeab0e Mon Sep 17 00:00:00 2001 From: zadam Date: Wed, 11 Nov 2020 23:15:48 +0100 Subject: [PATCH] fix overwriting / deleting auto links, closes #1406 --- src/entities/attribute.js | 4 ++++ src/routes/api/attributes.js | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/entities/attribute.js b/src/entities/attribute.js index 857531ffe..b5aecf6e1 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.js index 345ecfae4..98360a36c 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 deleted for (const toDeleteAttr of existingAttrs) { - toDeleteAttr.isDeleted = true; - toDeleteAttr.save(); + if (!toDeleteAttr.isAutoLink()) { + toDeleteAttr.isDeleted = true; + toDeleteAttr.save(); + } } }