mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-27 09:35:56 -05:00
Fix acceptableModes
This commit is contained in:
parent
4435408cdc
commit
458170390c
1 changed files with 4 additions and 4 deletions
|
@ -18,6 +18,8 @@ const Tabs = require('../../components/tabs/tabs.jsx');
|
||||||
const Page = require('../../components/page/www/page.jsx');
|
const Page = require('../../components/page/www/page.jsx');
|
||||||
const render = require('../../lib/render.jsx');
|
const render = require('../../lib/render.jsx');
|
||||||
|
|
||||||
|
const ACCEPTABLE_MODES = ['trending', 'popular', ''];
|
||||||
|
|
||||||
require('./search.scss');
|
require('./search.scss');
|
||||||
|
|
||||||
class Search extends React.Component {
|
class Search extends React.Component {
|
||||||
|
@ -64,7 +66,7 @@ class Search extends React.Component {
|
||||||
mode = mode.substring(0, term.indexOf('&'));
|
mode = mode.substring(0, term.indexOf('&'));
|
||||||
}
|
}
|
||||||
mode = decodeURIComponent(mode.split('+').join(' '));
|
mode = decodeURIComponent(mode.split('+').join(' '));
|
||||||
this.props.dispatch(navigationActions.setMode(mode));
|
this.setState({mode: mode});
|
||||||
}
|
}
|
||||||
componentDidUpdate (prevProps) {
|
componentDidUpdate (prevProps) {
|
||||||
if (this.props.searchTerm !== prevProps.searchTerm) {
|
if (this.props.searchTerm !== prevProps.searchTerm) {
|
||||||
|
@ -78,15 +80,13 @@ class Search extends React.Component {
|
||||||
}
|
}
|
||||||
const start = pathname.lastIndexOf('/');
|
const start = pathname.lastIndexOf('/');
|
||||||
const type = pathname.substring(start + 1, pathname.length);
|
const type = pathname.substring(start + 1, pathname.length);
|
||||||
const modeOptions = ['trending', 'popular', ''];
|
|
||||||
return {
|
return {
|
||||||
acceptableModes: modeOptions,
|
|
||||||
tab: type,
|
tab: type,
|
||||||
loadNumber: 16
|
loadNumber: 16
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
handleChangeSortMode (name, value) {
|
handleChangeSortMode (name, value) {
|
||||||
if (this.state.acceptableModes.indexOf(value) !== -1) {
|
if (ACCEPTABLE_MODES.indexOf(value) !== -1) {
|
||||||
const term = this.props.searchTerm.split(' ').join('+');
|
const term = this.props.searchTerm.split(' ').join('+');
|
||||||
window.location =
|
window.location =
|
||||||
`${window.location.origin}/search/${this.state.tab}?q=${term}&mode=${value}`;
|
`${window.location.origin}/search/${this.state.tab}?q=${term}&mode=${value}`;
|
||||||
|
|
Loading…
Reference in a new issue