redesign of search input. Saved search is now saved under active note and doesn't need page reload

This commit is contained in:
zadam
2019-03-29 23:24:41 +01:00
parent 8fb6edad67
commit 89b8e2bb08
12 changed files with 104 additions and 69 deletions

View File

@@ -1,6 +1,5 @@
"use strict";
const noteService = require('../../services/notes');
const repository = require('../../services/repository');
const noteCacheService = require('../../services/note_cache');
const log = require('../../services/log');
@@ -13,20 +12,6 @@ async function searchNotes(req) {
return noteIds.map(noteCacheService.getNotePath).filter(res => !!res);
}
async function saveSearchToNote(req) {
const content = {
searchString: req.params.searchString
};
const {note} = await noteService.createNote('root', req.params.searchString, content, {
json: true,
type: 'search',
mime: "application/json"
});
return { noteId: note.noteId };
}
async function searchFromNote(req) {
const note = await repository.getNote(req.params.noteId);
@@ -52,7 +37,7 @@ async function searchFromNote(req) {
noteIds = await searchFromRelation(note, relationName);
}
else {
noteIds = searchService.searchForNoteIds(json.searchString);
noteIds = await searchService.searchForNoteIds(json.searchString);
}
// we won't return search note's own noteId
@@ -100,6 +85,5 @@ async function searchFromRelation(note, relationName) {
module.exports = {
searchNotes,
saveSearchToNote,
searchFromNote
};