From 8901c3ec9154124be14cf825be8905f79f58fcc2 Mon Sep 17 00:00:00 2001 From: zadam Date: Mon, 26 Oct 2020 19:58:56 +0100 Subject: [PATCH] fix recent changes showing deleted search note, closes #1331 --- src/public/app/services/tree_cache.js | 4 ++-- src/routes/api/search.js | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/public/app/services/tree_cache.js b/src/public/app/services/tree_cache.js index 6db371627..c252aebbe 100644 --- a/src/public/app/services/tree_cache.js +++ b/src/public/app/services/tree_cache.js @@ -191,8 +191,8 @@ class TreeCache { if (note.type === 'search') { const searchResultNoteIds = await server.get('search-note/' + note.noteId); - if (!searchResultNoteIds) { - throw new Error(`Search note ${note.noteId} failed.`); + if (!Array.isArray(searchResultNoteIds)) { + throw new Error(`Search note ${note.noteId} failed: ${searchResultNoteIds}`); } // force to load all the notes at once instead of one by one diff --git a/src/routes/api/search.js b/src/routes/api/search.js index ef81122f6..201c7bbbf 100644 --- a/src/routes/api/search.js +++ b/src/routes/api/search.js @@ -38,7 +38,8 @@ async function searchFromNote(req) { } if (note.isDeleted) { - return [400, `Note ${req.params.noteId} is deleted.`]; + // this can be triggered from recent changes and it's harmless to return empty list rather than fail + return []; } if (note.type !== 'search') {