Restore Dewey Decimals message

The "no results found" message was showing instead due to some tricky
state management stuff.
This commit is contained in:
Alex Liebowitz 2016-12-30 07:42:47 -05:00
parent ed38e2ea75
commit 7e86cccd6c
2 changed files with 19 additions and 12 deletions

View file

@ -39,7 +39,7 @@ var App = React.createClass({
return { return {
viewingPage: viewingPage, viewingPage: viewingPage,
drawerOpen: drawerOpenRaw !== null ? JSON.parse(drawerOpenRaw) : true, drawerOpen: drawerOpenRaw !== null ? JSON.parse(drawerOpenRaw) : true,
pageArgs: val, pageArgs: typeof val !== 'undefined' ? val : null,
errorInfo: null, errorInfo: null,
modal: null, modal: null,
startNotice: null, startNotice: null,
@ -193,7 +193,7 @@ var App = React.createClass({
return <PublishPage />; return <PublishPage />;
case 'discover': case 'discover':
default: default:
return <DiscoverPage query={this.state.pageArgs} />; return <DiscoverPage {... this.state.pageArgs !== null ? {query: this.state.pageArgs} : {} } />;
} }
}, },
render: function() { render: function() {

View file

@ -268,20 +268,27 @@ var DiscoverPage = React.createClass({
componentDidUpdate: function() { componentDidUpdate: function() {
if (this.props.query != this.state.query) if (this.props.query != this.state.query)
{ {
this.handleSearchChanged(); this.handleSearchChanged(this.props.query);
} }
}, },
handleSearchChanged: function() { componentWillReceiveProps: function(nextProps, nextState) {
this.setState({ if (nextProps.query != nextState.query)
searching: true, {
query: this.props.query, this.handleSearchChanged(nextProps.query);
}); }
lighthouse.search(this.props.query, this.searchCallback);
}, },
componentDidMount: function() { handleSearchChanged: function(query) {
this.setState({
searching: true,
query: query,
});
lighthouse.search(query, this.searchCallback);
},
componentWillMount: function() {
document.title = "Discover"; document.title = "Discover";
if (this.props.query) { if (this.props.query) {
// Rendering with a query already typed // Rendering with a query already typed
@ -293,7 +300,7 @@ var DiscoverPage = React.createClass({
return { return {
results: [], results: [],
query: this.props.query, query: this.props.query,
searching: this.props.query && this.props.query.length > 0 searching: ('query' in this.props) && (this.props.query.length > 0)
}; };
}, },