quick search shows search errors #3221

This commit is contained in:
zadam 2022-12-17 11:58:30 +01:00
parent b202b43bf5
commit ecaa9a1d56
4 changed files with 28 additions and 7 deletions

View File

@ -98,9 +98,21 @@ export default class QuickSearchWidget extends BasicWidget {
this.$dropdownMenu.empty();
this.$dropdownMenu.append('<span class="dropdown-item disabled"><span class="bx bx-loader bx-spin"></span> Searching ...</span>');
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(`<span class="dropdown-item disabled">... and ${resultNoteIds.length - MAX_DISPLAYED_NOTES} more results.</span>`);
if (searchResultNoteIds.length > MAX_DISPLAYED_NOTES) {
this.$dropdownMenu.append(`<span class="dropdown-item disabled">... and ${searchResultNoteIds.length - MAX_DISPLAYED_NOTES} more results.</span>`);
}
const $showInFullButton = $('<a class="dropdown-item" tabindex="0">')

View File

@ -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;
}

View File

@ -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) {

View File

@ -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;
}