var fetchResultsStyle = { color: '#888', textAlign: 'center', fontSize: '1.2em' }; var SearchActive = React.createClass({ render: function() { return (
Looking up the Dewey Decimals
); } }); var searchNoResultsStyle = { textAlign: 'center' }, searchNoResultsMessageStyle = { fontStyle: 'italic', marginRight: '5px' }; var SearchNoResults = React.createClass({ render: function() { return (
No one has checked anything in for {this.props.query} yet.
); } }); var SearchResults = React.createClass({ render: function() { var rows = []; this.props.results.forEach(function(result) { if (!result.value.nsfw) { rows.push( ); } }); return (
{rows}
); } }); var searchRowStyle = { height: (24 * 7) + 'px', overflowY: 'hidden' }, searchRowImgStyle = { maxWidth: '100%', maxHeight: (24 * 7) + 'px', display: 'block', marginLeft: 'auto', marginRight: 'auto' }, searchRowTitleStyle = { fontWeight: 'bold' }, searchRowCostStyle = { float: 'right', }, searchRowDescriptionStyle = { color : '#444', marginTop: '12px', fontSize: '0.9em' }; var SearchResultRow = React.createClass({ getInitialState: function() { return { downloading: false } }, render: function() { return (
{'Photo
lbry://{this.props.name}

{this.props.title}

{this.props.description}

); } }); var FeaturedContentItem = React.createClass({ propTypes: { name: React.PropTypes.string, }, getInitialState: function() { return { metadata: null, title: null, amount: 0.0, }; }, componentWillMount: function() { lbry.search(this.props.name, (results) => { var result = results[0]; var metadata = result.value; this.setState({ metadata: metadata, amount: result.cost, title: metadata && metadata.title ? metadata.title : ('lbry://' + this.props.name), }) }); }, render: function() { if (this.state.metadata == null) { // Still waiting for metadata return null; } return ; } }); var featuredContentLegendStyle = { fontSize: '12px', color: '#aaa', verticalAlign: '15%', }; var FeaturedContent = React.createClass({ render: function() { return (

Featured Content

Community Content

); } }); var DiscoverPage = React.createClass({ userTypingTimer: null, componentDidUpdate: function() { if (this.props.query != this.state.query) { this.setState({ searching: true, query: this.props.query, }); lbry.search(this.props.query, this.searchCallback); } }, componentDidMount: function() { document.title = "Discover"; }, getInitialState: function() { return { results: [], query: this.props.query, searching: this.props.query && this.props.query.length > 0 }; }, searchCallback: function(results) { console.log('results:', results) console.log('search callback'); console.log(this.state); console.log(this.props); if (this.state.searching) //could have canceled while results were pending, in which case nothing to do { this.setState({ results: results, searching: false //multiple searches can be out, we're only done if we receive one we actually care about }); } }, render: function() { return (
{ this.state.searching ? : null } { !this.state.searching && this.props.query && this.state.results.length ? : null } { !this.state.searching && this.props.query && !this.state.results.length ? : null } { !this.props.query && !this.state.searching ? : null }
); } });