From 7495777d97d1030427df5bf812907e81ab8b7936 Mon Sep 17 00:00:00 2001 From: zadam Date: Thu, 13 Jan 2022 21:28:51 +0100 Subject: [PATCH] make `getAncestors` safe in respect to saved search --- src/becca/entities/note.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/becca/entities/note.js b/src/becca/entities/note.js index 2410d7a7f..f966927ee 100644 --- a/src/becca/entities/note.js +++ b/src/becca/entities/note.js @@ -865,11 +865,13 @@ class Note extends AbstractEntity { this.ancestorCache = []; for (const parent of this.parents) { - if (!noteIds.has(parent.noteId)) { - this.ancestorCache.push(parent); - noteIds.add(parent.noteId); + if (noteIds.has(parent.noteId)) { + continue; } + this.ancestorCache.push(parent); + noteIds.add(parent.noteId); + for (const ancestorNote of parent.getAncestors()) { if (!noteIds.has(ancestorNote.noteId)) { this.ancestorCache.push(ancestorNote);