1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 17:56:25 +00:00

Improve tag search by changing the logic

This commit is contained in:
asmsuechan
2017-10-13 11:40:10 +09:00
parent 78b12ae686
commit 7ab482184b

View File

@@ -3,9 +3,10 @@ import _ from 'lodash'
export default function searchFromNotes (notes, search) { export default function searchFromNotes (notes, search) {
if (search.trim().length === 0) return [] if (search.trim().length === 0) return []
const searchBlocks = search.split(' ').filter(block => { return block !== '' }) const searchBlocks = search.split(' ').filter(block => { return block !== '' })
let foundNotes = []
let foundNotes = findByWord(notes, searchBlocks[0])
searchBlocks.forEach((block) => { searchBlocks.forEach((block) => {
foundNotes = findByWord(notes, block) foundNotes = findByWord(foundNotes, block)
if (block.match(/^#.+/)) { if (block.match(/^#.+/)) {
foundNotes = foundNotes.concat(findByTag(notes, block)) foundNotes = foundNotes.concat(findByTag(notes, block))
} }