diff --git a/browser/main/Detail/index.js b/browser/main/Detail/index.js index 2c451085..3e6e450e 100644 --- a/browser/main/Detail/index.js +++ b/browser/main/Detail/index.js @@ -9,6 +9,7 @@ import ee from 'browser/main/lib/eventEmitter' import StatusBar from '../StatusBar' import i18n from 'browser/lib/i18n' import debounceRender from 'react-debounce-render' +import searchFromNotes from 'browser/lib/search' const OSX = global.process.platform === 'darwin' @@ -35,11 +36,38 @@ class Detail extends React.Component { } render () { - const { location, data, config } = this.props + const { location, data, params, config } = this.props let note = null if (location.query.key != null) { const noteKey = location.query.key - note = data.noteMap.get(noteKey) + let displayedNotes, noteKeys + + if (location.pathname.match(/\/home/) || location.pathname.match(/alltags/)) { + displayedNotes = data.noteMap.map(note => note) + } + if (location.pathname.match(/\/starred/)) { + displayedNotes = data.starredSet.toJS().map(uniqueKey => data.noteMap.get(uniqueKey)) + } + if (location.pathname.match(/\/searched/)) { + displayedNotes = searchFromNotes( + data.noteMap.map(note => note), + params.searchword + ) + } + if (location.pathname.match(/\/trashed/)) { + displayedNotes = data.trashedSet.toJS().map(uniqueKey => data.noteMap.get(uniqueKey)) + } + if (location.pathname.match(/\/tags/)) { + const listOfTags = params.tagname.split(' ') + displayedNotes = data.noteMap.map(note => note).filter(note => + listOfTags.every(tag => note.tags.includes(tag)) + ) + } + + noteKeys = displayedNotes.map(note => note.key) + if (noteKeys.includes(noteKey)) { + note = data.noteMap.get(noteKey) + } } if (note == null) {