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

View file

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