Skip to content
Prev Previous commit
Improve tag search by changing the logic
  • Loading branch information
asmsuechan committed Oct 13, 2017
commit 7ab482184bc4d1dea9cfbd79e03f36c562c7b752
5 changes: 3 additions & 2 deletions browser/lib/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import _ from 'lodash'
export default function searchFromNotes (notes, search) {
if (search.trim().length === 0) return []
const searchBlocks = search.split(' ').filter(block => { return block !== '' })
let foundNotes = []

let foundNotes = findByWord(notes, searchBlocks[0])
searchBlocks.forEach((block) => {
foundNotes = findByWord(notes, block)
foundNotes = findByWord(foundNotes, block)
if (block.match(/^#.+/)) {
foundNotes = foundNotes.concat(findByTag(notes, block))
}
Expand Down