diff --git a/js/page/show.js b/js/page/show.js index c9b509a81..34baa65a9 100644 --- a/js/page/show.js +++ b/js/page/show.js @@ -29,29 +29,39 @@ var formatItemStyle = { var FormatItem = React.createClass({ propTypes: { - metadata: React.PropTypes.object, - name: React.PropTypes.string, - amount: React.PropTypes.double, + results: React.PropTypes.object, }, render: function() { + var results = this.props.results; + var name = results.name; + var thumbnail = results.thumbnail; + var title = results.title; + var amount = results.cost_est ? results.cost_est : 0.0; + var description = results.description; + var author = results.author; + var language = results.language; + var license = results.license; + var fileContentType = results.content_type; + return (
- {'Photo + {'Photo
-

Address: {this.props.name}

+

Address: {name}

+

Content-Type: {fileContentType}

-
- +
+     - +
-

{this.props.metadata.description}

+

{description}

- Author: {this.props.metadata.author}
- Language: {this.props.metadata.language}
- License: {this.props.metadata.license}
+ Author: {author}
+ Language: {language}
+ License: {license}
@@ -61,41 +71,29 @@ var FormatItem = React.createClass({ var FormatsSection = React.createClass({ propTypes: { + results: React.PropTypes.object, name: React.PropTypes.string, }, - getInitialState: function() { - return { - metadata: null, - amount: 0.0, - }; - }, - componentWillMount: function() { - lbry.resolveName(this.props.name, (metadata) => { - this.setState({ - metadata: metadata, - }) - }); - lbry.search(this.props.name, (results) => { - this.setState({ - amount: (results ? results[0].cost_est : 0.0) - }); - }); - }, render: function() { - if (this.state.metadata == null) { - // Still waiting for metadata - return null; - } + var name = this.props.name; + var format = this.props.results; + var title = format.title; - var format = this.state.metadata; + if(format == null) + { + return ( +
+

Sorry, no results found for "{name}".

+
); + } return (
-

{this.state.metadata.title}

+

{title}

{/* In future, anticipate multiple formats, just a guess at what it could look like - // var formats = metadata.formats + // var formats = this.props.results.formats // return ({formats.map(function(format,i){ */} - + {/* })}); */}
); } @@ -105,11 +103,34 @@ var DetailPage = React.createClass({ propTypes: { name: React.PropTypes.string, }, + getInitialState: function() { + return { + results: null, + searching: true, + }; + }, + componentWillMount: function() { + lbry.search(this.props.name, (results) => { + this.setState({ + results: results[0], + searching: false, + }); + }); + }, render: function() { + if (this.state.results == null && this.state.searching) { + // Still waiting for metadata + return null; + } + + var name = this.props.name; + var metadata = this.state.metadata; + var results = this.state.results; + return (
- +