Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions browser/main/NoteList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,10 @@ class NoteList extends React.Component {
}

if (location.pathname.match(/\/searched/)) {
const searchInputText = document.getElementsByClassName('searchInput')[0].value
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the crash reason #1743

if (searchInputText === '') {
const searchInputText = params.searchword
const allNotes = data.noteMap.map((note) => note)
this.contextNotes = allNotes
if (searchInputText === undefined || searchInputText === '') {
return this.sortByPin(this.contextNotes)
}
return searchFromNotes(this.contextNotes, searchInputText)
Expand Down
15 changes: 12 additions & 3 deletions browser/main/TopBar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ class TopBar extends React.Component {
}

componentDidMount () {
const { params } = this.props
const searchWord = params.searchword
if (searchWord !== undefined) {
this.setState({
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Restore search state from /searched/:searchword

search: searchWord,
isSearching: true
})
}
ee.on('top:focus-search', this.focusSearchHandler)
ee.on('code:init', this.codeInitHandler)
}
Expand Down Expand Up @@ -97,9 +105,10 @@ class TopBar extends React.Component {
this.setState({
isConfirmTranslation: true
})
router.push('/searched')
const keyword = this.refs.searchInput.value
router.push(`/searched/${encodeURIComponent(keyword)}`)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

push to /searched/:searchword

this.setState({
search: this.refs.searchInput.value
search: keyword
})
}
}
Expand All @@ -108,7 +117,7 @@ class TopBar extends React.Component {
const { router } = this.context
const keyword = this.refs.searchInput.value
if (this.state.isAlphabet || this.state.isConfirmTranslation) {
router.push('/searched')
router.push(`/searched/${encodeURIComponent(keyword)}`)
} else {
e.preventDefault()
}
Expand Down
4 changes: 3 additions & 1 deletion browser/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ ReactDOM.render((
<IndexRedirect to='/home' />
<Route path='home' />
<Route path='starred' />
<Route path='searched' />
<Route path='searched'>
<Route path=':searchword' />
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/searched/:searchword

</Route>
<Route path='trashed' />
<Route path='alltags' />
<Route path='tags'>
Expand Down