From 1fcb99fa60094f6a7544b6cc1d56f542499d8b96 Mon Sep 17 00:00:00 2001 From: zadam Date: Wed, 23 Sep 2020 22:27:19 +0200 Subject: [PATCH] fix duplication of search results when conforming to multiple expressions in OR relation, closes #1262 --- src/services/search/note_set.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/services/search/note_set.js b/src/services/search/note_set.js index 626730d68..6f442d401 100644 --- a/src/services/search/note_set.js +++ b/src/services/search/note_set.js @@ -31,8 +31,12 @@ class NoteSet { } mergeIn(anotherNoteSet) { - this.notes = this.notes.concat(anotherNoteSet.notes); - this.noteIdSet = new Set(this.notes.map(note => note.noteId)); + for (const note of anotherNoteSet.notes) { + if (!this.noteIdSet.has(note.noteId)) { + this.noteIdSet.add(note.noteId); + this.notes.push(note); + } + } } minus(anotherNoteSet) {