Fix setting mode

This commit is contained in:
kyleplo 2018-08-22 14:17:26 -04:00 committed by GitHub
parent 458170390c
commit 78b88443c0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -37,6 +37,20 @@ class Search extends React.Component {
this.state.mode = ''; this.state.mode = '';
this.state.offset = 0; this.state.offset = 0;
this.state.loadMore = false; this.state.loadMore = false;
let mode = '';
const m = query.lastIndexOf('mode=');
if (m !== -1) {
mode = query.substring(m + 5, query.length).toLowerCase();
}
while (mode.indexOf('/') > -1) {
mode = mode.substring(0, term.indexOf('/'));
}
while (term.indexOf('&') > -1) {
mode = mode.substring(0, term.indexOf('&'));
}
mode = decodeURIComponent(mode.split('+').join(' '));
this.state.mode = mode;
} }
componentDidMount () { componentDidMount () {
const query = window.location.search; const query = window.location.search;
@ -53,20 +67,6 @@ class Search extends React.Component {
} }
term = decodeURIComponent(term.split('+').join(' ')); term = decodeURIComponent(term.split('+').join(' '));
this.props.dispatch(navigationActions.setSearchTerm(term)); this.props.dispatch(navigationActions.setSearchTerm(term));
let mode = '';
const m = query.lastIndexOf('mode=');
if (m !== -1) {
mode = query.substring(m + 5, query.length).toLowerCase();
}
while (mode.indexOf('/') > -1) {
mode = mode.substring(0, term.indexOf('/'));
}
while (term.indexOf('&') > -1) {
mode = mode.substring(0, term.indexOf('&'));
}
mode = decodeURIComponent(mode.split('+').join(' '));
this.setState({mode: mode});
} }
componentDidUpdate (prevProps) { componentDidUpdate (prevProps) {
if (this.props.searchTerm !== prevProps.searchTerm) { if (this.props.searchTerm !== prevProps.searchTerm) {