add tags filter in LibraryList & LibraryMap

This commit is contained in:
axolotle
2021-06-14 17:00:18 +02:00
parent fb7aa12bd9
commit 3c324e0a3c
3 changed files with 17 additions and 8 deletions
+7 -1
View File
@@ -124,10 +124,16 @@ export function searchInNode (search, node) {
if (key === 'authors') {
match = node[key].some(author => author.name.toLowerCase().includes(search))
} else {
console.log(node[key].toLowerCase(), search)
match = node[key].toLowerCase().includes(search)
}
if (match) return true
}
return false
}
export function tagsInNode (tags, nodeTags) {
if (tags.length === 0) return true
if (!nodeTags || nodeTags.length === 0) return false
return tags.every(tag => nodeTags.some(nodeTag => nodeTag.name === tag))
}