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

Filtering displayed notes in Detail component

This commit is contained in:
Сергей Иванов
2018-07-04 13:33:47 +03:00
parent 9d9109e9e5
commit 680eaa1d4a

View File

@@ -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) {