1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 01:36:22 +00:00

Merge pull request #766 from asmsuechan/improve-search

Context search
This commit is contained in:
SuenagaRyota
2017-08-05 22:56:31 +09:00
committed by GitHub
3 changed files with 5 additions and 6 deletions

View File

@@ -1,7 +1,6 @@
import _ from 'lodash'
export default function searchFromNotes (data, search) {
let notes = data.noteMap.map((note) => note)
export default function searchFromNotes (notes, search) {
if (search.trim().length === 0) return []
let searchBlocks = search.split(' ')
searchBlocks.forEach((block) => {

View File

@@ -246,7 +246,7 @@ class NoteList extends React.Component {
if (searchInputText === '') {
router.push('/home')
}
return searchFromNotes(this.props.data, searchInputText)
return searchFromNotes(this.notes, searchInputText)
}
if (location.pathname.match(/\/trashed/)) {

View File

@@ -5,7 +5,7 @@ import _ from 'lodash'
const pickContents = (notes) => notes.map((note) => { return note.content })
let noteList = { noteMap: [] }
let notes = []
let note1, note2
test.before(t => {
@@ -14,7 +14,7 @@ test.before(t => {
note1 = dummyNote(data1)
note2 = dummyNote(data2)
noteList.noteMap = [note1, note2]
notes = [note1, note2]
})
test('it can find notes by tags or words', t => {
@@ -30,7 +30,7 @@ test('it can find notes by tags or words', t => {
testCases.forEach((testCase) => {
const [input, expectedContents] = testCase
const results = searchFromNotes(noteList, input)
const results = searchFromNotes(notes, input)
t.true(_.isEqual(pickContents(results).sort(), expectedContents.sort()))
})
})