mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-12-03 12:27:30 -05:00
Fix setting mode
This commit is contained in:
parent
458170390c
commit
78b88443c0
1 changed files with 14 additions and 14 deletions
|
@ -37,6 +37,20 @@ class Search extends React.Component {
|
|||
this.state.mode = '';
|
||||
this.state.offset = 0;
|
||||
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 () {
|
||||
const query = window.location.search;
|
||||
|
@ -53,20 +67,6 @@ class Search extends React.Component {
|
|||
}
|
||||
term = decodeURIComponent(term.split('+').join(' '));
|
||||
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) {
|
||||
if (this.props.searchTerm !== prevProps.searchTerm) {
|
||||
|
|
Loading…
Reference in a new issue