fix searching by label

This commit is contained in:
zadam 2021-07-04 21:05:47 +02:00
parent 8d3a3d4873
commit e25b965cb3
3 changed files with 8 additions and 4 deletions

View File

@ -28,7 +28,7 @@ function formatAttrForSearch(attr, searchWithValue) {
} }
function formatValue(val) { function formatValue(val) {
if (!/[^\w_-]/.test(val)) { if (!/[^\w_]/.test(val)) {
return val; return val;
} }
else if (!val.includes('"')) { else if (!val.includes('"')) {

View File

@ -60,7 +60,11 @@ const BUILTIN_ATTRIBUTES = [
]; ];
function getNotesWithLabel(name, value) { function getNotesWithLabel(name, value) {
return searchService.searchNotes(formatAttrForSearch({type: 'label', name, value}, true)); const query = formatAttrForSearch({type: 'label', name, value}, true);
return searchService.searchNotes(query, {
includeArchivedNotes: true,
ignoreHoistedNote: true
});
} }
function getNoteIdsWithLabels(names) { function getNoteIdsWithLabels(names) {

View File

@ -136,8 +136,8 @@ function parseQueryToExpression(query, searchContext) {
* @param {string} query * @param {string} query
* @return {Note[]} * @return {Note[]}
*/ */
function searchNotes(query) { function searchNotes(query, params = {}) {
const searchResults = findResultsWithQuery(query, new SearchContext()); const searchResults = findResultsWithQuery(query, new SearchContext(params));
return searchResults.map(sr => becca.notes[sr.noteId]); return searchResults.map(sr => becca.notes[sr.noteId]);
} }