From ecaa9a1d56cf99d3701a1058b5d1356f8dc7576d Mon Sep 17 00:00:00 2001 From: zadam Date: Sat, 17 Dec 2022 11:58:30 +0100 Subject: [PATCH] quick search shows search errors #3221 --- src/public/app/widgets/quick_search.js | 20 ++++++++++++++++---- src/public/stylesheets/style.css | 6 +++++- src/routes/api/search.js | 7 ++++++- src/services/search/services/lex.js | 2 +- 4 files changed, 28 insertions(+), 7 deletions(-) diff --git a/src/public/app/widgets/quick_search.js b/src/public/app/widgets/quick_search.js index e275756b1..5b7370263 100644 --- a/src/public/app/widgets/quick_search.js +++ b/src/public/app/widgets/quick_search.js @@ -98,9 +98,21 @@ export default class QuickSearchWidget extends BasicWidget { this.$dropdownMenu.empty(); this.$dropdownMenu.append(' Searching ...'); - const resultNoteIds = await server.get('quick-search/' + encodeURIComponent(searchString)); + const {searchResultNoteIds, error} = await server.get('quick-search/' + encodeURIComponent(searchString)); - const displayedNoteIds = resultNoteIds.slice(0, Math.min(MAX_DISPLAYED_NOTES, resultNoteIds.length)); + if (error) { + this.$searchString.tooltip({ + trigger: 'manual', + title: "Search error: " + error, + placement: 'right' + }); + + this.$searchString.tooltip("show"); + + setTimeout(() => this.$searchString.tooltip("dispose"), 4000); + } + + const displayedNoteIds = searchResultNoteIds.slice(0, Math.min(MAX_DISPLAYED_NOTES, searchResultNoteIds.length)); this.$dropdownMenu.empty(); @@ -129,8 +141,8 @@ export default class QuickSearchWidget extends BasicWidget { this.$dropdownMenu.append($link); } - if (resultNoteIds.length > MAX_DISPLAYED_NOTES) { - this.$dropdownMenu.append(`... and ${resultNoteIds.length - MAX_DISPLAYED_NOTES} more results.`); + if (searchResultNoteIds.length > MAX_DISPLAYED_NOTES) { + this.$dropdownMenu.append(`... and ${searchResultNoteIds.length - MAX_DISPLAYED_NOTES} more results.`); } const $showInFullButton = $('') diff --git a/src/public/stylesheets/style.css b/src/public/stylesheets/style.css index fc6361bc3..f093c236e 100644 --- a/src/public/stylesheets/style.css +++ b/src/public/stylesheets/style.css @@ -385,7 +385,11 @@ table.promoted-attributes-in-tooltip td, table.promoted-attributes-in-tooltip th font-size: var(--main-font-size) !important; } -.tooltip .arrow { +.tooltip .arrow::before { + border-right-color: var(--main-border-color) !important; +} + +.note-tooltip.tooltip .arrow { display: none; } diff --git a/src/routes/api/search.js b/src/routes/api/search.js index b9c1f5412..7ca442724 100644 --- a/src/routes/api/search.js +++ b/src/routes/api/search.js @@ -58,8 +58,13 @@ function quickSearch(req) { fuzzyAttributeSearch: false }); - return searchService.findResultsWithQuery(searchString, searchContext) + const resultNoteIds = searchService.findResultsWithQuery(searchString, searchContext) .map(sr => sr.noteId); + + return { + searchResultNoteIds: resultNoteIds, + error: searchContext.getError() + }; } function search(req) { diff --git a/src/services/search/services/lex.js b/src/services/search/services/lex.js index 470ba5526..d7a3fb83e 100644 --- a/src/services/search/services/lex.js +++ b/src/services/search/services/lex.js @@ -76,7 +76,7 @@ function lex(str) { quotes = false; } else { - // it's a quote but within other kind of quotes so it's valid as a literal character + // it's a quote but within other kind of quotes, so it's valid as a literal character currentWord += chr; }