mirror of
https://github.com/zadam/trilium.git
synced 2025-11-18 03:00:41 +01:00
refactoring of "some path" WIP
This commit is contained in:
@@ -24,7 +24,7 @@ class NoteFlatTextExp extends Expression {
|
||||
*/
|
||||
function searchDownThePath(note, tokens, path) {
|
||||
if (tokens.length === 0) {
|
||||
const retPath = beccaService.getSomePath(note, path);
|
||||
const retPath = this.getNotePath(note, path);
|
||||
|
||||
if (retPath) {
|
||||
const noteId = retPath[retPath.length - 1];
|
||||
@@ -131,6 +131,17 @@ class NoteFlatTextExp extends Expression {
|
||||
return resultNoteSet;
|
||||
}
|
||||
|
||||
getNotePath(note, path) {
|
||||
if (path.length === 0) {
|
||||
return note.getBestNotePath();
|
||||
} else {
|
||||
const closestNoteId = path[0];
|
||||
const closestNoteBestNotePath = becca.getNote(closestNoteId).getBestNotePathString();
|
||||
|
||||
return [...closestNoteBestNotePath, ...path.slice(1)];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns noteIds which have at least one matching tokens
|
||||
*
|
||||
|
||||
@@ -157,7 +157,7 @@ function findResultsWithExpression(expression, searchContext) {
|
||||
const searchResults = noteSet.notes
|
||||
.filter(note => !note.isDeleted)
|
||||
.map(note => {
|
||||
const notePathArray = executionContext.noteIdToNotePath[note.noteId] || beccaService.getSomePath(note);
|
||||
const notePathArray = executionContext.noteIdToNotePath[note.noteId] || note.getBestNotePath();
|
||||
|
||||
if (!notePathArray) {
|
||||
throw new Error(`Can't find note path for note ${JSON.stringify(note.getPojo())}`);
|
||||
|
||||
Reference in New Issue
Block a user