mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-14 02:06:29 +00:00
Improve context search
This commit is contained in:
@@ -51,6 +51,7 @@ class NoteList extends React.Component {
|
|||||||
this.jumpNoteByHash = this.jumpNoteByHashHandler.bind(this)
|
this.jumpNoteByHash = this.jumpNoteByHashHandler.bind(this)
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
|
contextNotes: []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,6 +91,7 @@ class NoteList extends React.Component {
|
|||||||
|
|
||||||
if (this.notes.length > 0 && location.query.key == null) {
|
if (this.notes.length > 0 && location.query.key == null) {
|
||||||
let { router } = this.context
|
let { router } = this.context
|
||||||
|
if (!location.pathname.match(/\/searched/)) this.setState({contextNotes: this.getContextNotes()})
|
||||||
router.replace({
|
router.replace({
|
||||||
pathname: location.pathname,
|
pathname: location.pathname,
|
||||||
query: {
|
query: {
|
||||||
@@ -245,9 +247,9 @@ class NoteList extends React.Component {
|
|||||||
if (location.pathname.match(/\/searched/)) {
|
if (location.pathname.match(/\/searched/)) {
|
||||||
const searchInputText = document.getElementsByClassName('searchInput')[0].value
|
const searchInputText = document.getElementsByClassName('searchInput')[0].value
|
||||||
if (searchInputText === '') {
|
if (searchInputText === '') {
|
||||||
router.push('/home')
|
return this.state.contextNotes
|
||||||
}
|
}
|
||||||
return searchFromNotes(this.notes, searchInputText)
|
return searchFromNotes(this.state.contextNotes, searchInputText)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (location.pathname.match(/\/trashed/)) {
|
if (location.pathname.match(/\/trashed/)) {
|
||||||
@@ -255,6 +257,12 @@ class NoteList extends React.Component {
|
|||||||
.map((uniqueKey) => data.noteMap.get(uniqueKey))
|
.map((uniqueKey) => data.noteMap.get(uniqueKey))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return this.getContextNotes()
|
||||||
|
}
|
||||||
|
|
||||||
|
// get notes in a specific folder
|
||||||
|
getContextNotes () {
|
||||||
|
let { data, params } = this.props
|
||||||
let storageKey = params.storageKey
|
let storageKey = params.storageKey
|
||||||
let folderKey = params.folderKey
|
let folderKey = params.folderKey
|
||||||
let storage = data.storageMap.get(storageKey)
|
let storage = data.storageMap.get(storageKey)
|
||||||
|
|||||||
Reference in New Issue
Block a user