From cba9b92202e0f234d2dad994c075c86a82519c00 Mon Sep 17 00:00:00 2001 From: zadam Date: Wed, 30 Sep 2020 22:34:18 +0200 Subject: [PATCH] make sure the attribute is not duplicated in TreeCache and NoteCache, #1278 --- src/entities/note.js | 1 + src/public/app/entities/note_short.js | 11 ++++++++++- src/public/stylesheets/style.css | 7 +++++-- src/services/note_cache/entities/note.js | 13 ++++++++++++- src/services/note_cache/similarity.js | 4 ++++ 5 files changed, 32 insertions(+), 4 deletions(-) diff --git a/src/entities/note.js b/src/entities/note.js index 1db0e8abb..873a997e1 100644 --- a/src/entities/note.js +++ b/src/entities/note.js @@ -373,6 +373,7 @@ class Note extends Entity { return false; } + // FIXME: this code is quite questionable, one problem is that other caches (TreeCache, NoteCache) have nothing like that if (attr.isDefinition()) { const firstDefinitionIndex = attributes.findIndex(el => el.type === attr.type && el.name === attr.name); diff --git a/src/public/app/entities/note_short.js b/src/public/app/entities/note_short.js index 384e4f35d..a3e23112d 100644 --- a/src/public/app/entities/note_short.js +++ b/src/public/app/entities/note_short.js @@ -205,7 +205,16 @@ class NoteShort { } } - noteAttributeCache.attributes[this.noteId] = attrArrs.flat(); + noteAttributeCache.attributes[this.noteId] = []; + const addedAttributeIds = new Set(); + + for (const attr of attrArrs.flat()) { + if (!addedAttributeIds.has(attr.attributeId)) { + addedAttributeIds.add(attr.attributeId); + + noteAttributeCache.attributes[this.noteId].push(attr); + } + } } return noteAttributeCache.attributes[this.noteId]; diff --git a/src/public/stylesheets/style.css b/src/public/stylesheets/style.css index dc1cfa22c..6d96c7795 100644 --- a/src/public/stylesheets/style.css +++ b/src/public/stylesheets/style.css @@ -852,7 +852,10 @@ ul.fancytree-container li { contain: layout paint; } -/** ckeditor's autocomplete */ +/** + ckeditor's autocomplete + should be higher than 1070 of tooltip +*/ .ck.ck-balloon-panel { - z-index: 1001; + z-index: 1101; } diff --git a/src/services/note_cache/entities/note.js b/src/services/note_cache/entities/note.js index 0ed575941..6793ad476 100644 --- a/src/services/note_cache/entities/note.js +++ b/src/services/note_cache/entities/note.js @@ -92,7 +92,18 @@ class Note { } } - this.attributeCache = parentAttributes.concat(templateAttributes); + this.attributeCache = []; + + const addedAttributeIds = new Set(); + + for (const attr of parentAttributes.concat(templateAttributes)) { + if (!addedAttributeIds.has(attr.attributeId)) { + addedAttributeIds.add(attr.attributeId); + + this.attributeCache.push(attr); + } + } + this.inheritableAttributeCache = []; for (const attr of this.attributeCache) { diff --git a/src/services/note_cache/similarity.js b/src/services/note_cache/similarity.js index 28619c944..d80d399e6 100644 --- a/src/services/note_cache/similarity.js +++ b/src/services/note_cache/similarity.js @@ -106,6 +106,10 @@ function buildRewardMap(note) { addToRewardMap(attr.name, reward); } + if (attr.name === 'cliptype') { + reward /= 2; + } + let value = attr.value; if (value.startsWith('http')) {