mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
renaming/refactoring of search services
This commit is contained in:
parent
76c0e5b2b8
commit
015cd68756
2
src/public/javascripts/services/bootstrap.js
vendored
2
src/public/javascripts/services/bootstrap.js
vendored
@ -17,7 +17,7 @@ import messagingService from './messaging.js';
|
||||
import noteDetailService from './note_detail.js';
|
||||
import noteType from './note_type.js';
|
||||
import protected_session from './protected_session.js';
|
||||
import searchTreeService from './search_tree.js';
|
||||
import searchNotesService from './search_notes.js';
|
||||
import ScriptApi from './script_api.js';
|
||||
import ScriptContext from './script_context.js';
|
||||
import sync from './sync.js';
|
||||
|
@ -11,7 +11,7 @@ import jumpToNoteDialog from "../dialogs/jump_to_note.js";
|
||||
import noteSourceDialog from "../dialogs/note_source.js";
|
||||
import recentChangesDialog from "../dialogs/recent_changes.js";
|
||||
import sqlConsoleDialog from "../dialogs/sql_console.js";
|
||||
import searchTreeService from "./search_tree.js";
|
||||
import searchNotesService from "./search_notes.js";
|
||||
import labelsDialog from "../dialogs/labels.js";
|
||||
import protectedSessionService from "./protected_session.js";
|
||||
|
||||
@ -39,8 +39,8 @@ function registerEntrypoints() {
|
||||
$("#recent-notes-button").click(recentNotesDialog.showDialog);
|
||||
utils.bindShortcut('ctrl+e', recentNotesDialog.showDialog);
|
||||
|
||||
$("#toggle-search-button").click(searchTreeService.toggleSearch);
|
||||
utils.bindShortcut('ctrl+s', searchTreeService.toggleSearch);
|
||||
$("#toggle-search-button").click(searchNotesService.toggleSearch);
|
||||
utils.bindShortcut('ctrl+s', searchNotesService.toggleSearch);
|
||||
|
||||
$(".show-labels-button").click(labelsDialog.showDialog);
|
||||
utils.bindShortcut('alt+l', labelsDialog.showDialog);
|
||||
|
File diff suppressed because one or more lines are too long
@ -1,11 +1,11 @@
|
||||
"use strict";
|
||||
|
||||
const autocompleteService = require('../../services/autocomplete');
|
||||
const autocompleteService = require('../../services/note_cache');
|
||||
|
||||
async function getAutocomplete(req) {
|
||||
const query = req.query.query;
|
||||
|
||||
const results = autocompleteService.getResults(query);
|
||||
const results = autocompleteService.findNotes(query);
|
||||
|
||||
return results.map(res => {
|
||||
return {
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
const sql = require('../../services/sql');
|
||||
const noteService = require('../../services/notes');
|
||||
const autocompleteService = require('../../services/autocomplete');
|
||||
const autocompleteService = require('../../services/note_cache');
|
||||
const utils = require('../../services/utils');
|
||||
const parseFilters = require('../../services/parse_filters');
|
||||
const buildSearchQuery = require('../../services/build_search_query');
|
||||
@ -21,13 +21,13 @@ async function searchNotes(req) {
|
||||
let searchTextResults = null;
|
||||
|
||||
if (searchText.trim().length > 0) {
|
||||
searchTextResults = autocompleteService.getResults(searchText);
|
||||
searchTextResults = autocompleteService.findNotes(searchText);
|
||||
|
||||
let fullTextNoteIds = await getFullTextResults(searchText);
|
||||
|
||||
for (const noteId of fullTextNoteIds) {
|
||||
if (!searchTextResults.some(item => item.noteId === noteId)) {
|
||||
const result = autocompleteService.getResult(noteId);
|
||||
const result = autocompleteService.getNotePath(noteId);
|
||||
|
||||
if (result) {
|
||||
searchTextResults.push(result);
|
||||
@ -42,7 +42,7 @@ async function searchNotes(req) {
|
||||
results = labelFiltersNoteIds.filter(item => searchTextResults.includes(item.noteId));
|
||||
}
|
||||
else if (labelFiltersNoteIds) {
|
||||
results = labelFiltersNoteIds.map(autocompleteService.getResult).filter(res => !!res);
|
||||
results = labelFiltersNoteIds.map(autocompleteService.getNotePath).filter(res => !!res);
|
||||
}
|
||||
else {
|
||||
results = searchTextResults;
|
||||
|
@ -34,7 +34,7 @@ async function load() {
|
||||
}
|
||||
}
|
||||
|
||||
function getResults(query) {
|
||||
function findNotes(query) {
|
||||
if (!noteTitles || query.length <= 2) {
|
||||
return [];
|
||||
}
|
||||
@ -195,15 +195,7 @@ function getSomePath(noteId, path) {
|
||||
return false;
|
||||
}
|
||||
|
||||
function getNoteTitle(noteId) {
|
||||
if (noteId in noteTitles) {
|
||||
return noteTitles[noteId];
|
||||
}
|
||||
|
||||
return protectedNoteTitles[noteId];
|
||||
}
|
||||
|
||||
function getResult(noteId) {
|
||||
function getNotePath(noteId) {
|
||||
const retPath = getSomePath(noteId, []);
|
||||
|
||||
if (retPath) {
|
||||
@ -277,7 +269,6 @@ eventService.subscribe(eventService.ENTER_PROTECTED_SESSION, async () => {
|
||||
sqlInit.dbReady.then(() => utils.stopWatch("Autocomplete load", load));
|
||||
|
||||
module.exports = {
|
||||
getResults,
|
||||
getNoteTitle,
|
||||
getResult
|
||||
findNotes,
|
||||
getNotePath
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user