added IN operator to search, closes #534

This commit is contained in:
zadam
2019-11-17 09:07:35 +01:00
parent a1262aaaf3
commit 1a87190f43
3 changed files with 35 additions and 1 deletions

View File

@@ -255,6 +255,25 @@ function isArchived(noteId) {
return isNotePathArchived(notePath);
}
/**
* @param {string} noteId
* @param {string} ancestorNoteId
* @return {boolean} - true if given noteId has ancestorNoteId in any of its paths (even archived)
*/
function isInAncestor(noteId, ancestorNoteId) {
if (ancestorNoteId === noteId) { // special case
return true;
}
for (const parentNoteId of childToParent[noteId] || []) {
if (isInAncestor(parentNoteId, ancestorNoteId)) {
return true;
}
}
return false;
}
function getNoteTitleFromPath(notePath) {
const pathArr = notePath.split("/");
@@ -529,6 +548,7 @@ module.exports = {
getNoteTitleFromPath,
isAvailable,
isArchived,
isInAncestor,
load,
findSimilarNotes
};