From 6987b762dda30563228e4284aef4cda0f5ae9d48 Mon Sep 17 00:00:00 2001 From: asmsuechan Date: Sat, 5 Aug 2017 22:23:33 +0900 Subject: [PATCH 1/2] Make context-search work --- browser/lib/search.js | 3 +-- browser/main/NoteList/index.js | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/browser/lib/search.js b/browser/lib/search.js index f119421b..1914bb81 100644 --- a/browser/lib/search.js +++ b/browser/lib/search.js @@ -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) => { diff --git a/browser/main/NoteList/index.js b/browser/main/NoteList/index.js index bac7767d..9c0b3c2d 100644 --- a/browser/main/NoteList/index.js +++ b/browser/main/NoteList/index.js @@ -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/)) { From 886d7b72275f9165df132293b51564afba346b4f Mon Sep 17 00:00:00 2001 From: asmsuechan Date: Sat, 5 Aug 2017 22:48:04 +0900 Subject: [PATCH 2/2] Fix test --- tests/lib/search-test.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/lib/search-test.js b/tests/lib/search-test.js index 253469be..e99a3612 100644 --- a/tests/lib/search-test.js +++ b/tests/lib/search-test.js @@ -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())) }) })