From b12008e3130d1d8f93a841dcd0ce336f73a659ec Mon Sep 17 00:00:00 2001 From: zadam Date: Tue, 17 Nov 2020 20:44:38 +0100 Subject: [PATCH] more robust search in face of inconsistent cache --- src/services/search/services/search.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/services/search/services/search.js b/src/services/search/services/search.js index ca2c9f178..eab2b32af 100644 --- a/src/services/search/services/search.js +++ b/src/services/search/services/search.js @@ -17,10 +17,14 @@ const utils = require('../../utils.js'); */ function findNotesWithExpression(expression) { const hoistedNote = noteCache.notes[hoistedNoteService.getHoistedNoteId()]; - const allNotes = (hoistedNote && hoistedNote.noteId !== 'root') + let allNotes = (hoistedNote && hoistedNote.noteId !== 'root') ? hoistedNote.subtreeNotes : Object.values(noteCache.notes); + // in the process of loading data sometimes we create "skeleton" note instances which are expected to be filled later + // in case of inconsistent data this might not work and search will then crash on these + allNotes = allNotes.filter(note => note.type !== undefined); + const allNoteSet = new NoteSet(allNotes); const searchContext = {