Make Show page use lbry.getClaimInfo() and lbry.getCostEstimate()

This commit is contained in:
Alex Liebowitz 2016-07-30 03:47:31 -04:00
parent 1fcf1b4325
commit 7c77f166cd

View file

@ -29,19 +29,23 @@ var formatItemStyle = {
var FormatItem = React.createClass({ var FormatItem = React.createClass({
propTypes: { propTypes: {
results: React.PropTypes.object, claimInfo: React.PropTypes.object,
amount: React.PropTypes.number,
name: React.PropTypes.string,
}, },
render: function() { render: function() {
var results = this.props.results; var name = this.props.name;
var name = results.name;
var thumbnail = results.thumbnail; var claimInfo = this.props.claimInfo;
var title = results.title; var thumbnail = claimInfo.thumbnail;
var amount = results.cost_est ? results.cost_est : 0.0; var title = claimInfo.title;
var description = results.description; var description = claimInfo.description;
var author = results.author; var author = claimInfo.author;
var language = results.language; var language = claimInfo.language;
var license = results.license; var license = claimInfo.license;
var fileContentType = results['content-type']; var fileContentType = claimInfo['content-type'];
var amount = this.props.amount || 0.0;
return ( return (
<div className="row-fluid" style={formatItemStyle}> <div className="row-fluid" style={formatItemStyle}>
@ -71,12 +75,13 @@ var FormatItem = React.createClass({
var FormatsSection = React.createClass({ var FormatsSection = React.createClass({
propTypes: { propTypes: {
results: React.PropTypes.object, claimInfo: React.PropTypes.object,
amount: React.PropTypes.number,
name: React.PropTypes.string, name: React.PropTypes.string,
}, },
render: function() { render: function() {
var name = this.props.name; var name = this.props.name;
var format = this.props.results; var format = this.props.claimInfo;
var title = format.title; var title = format.title;
if(format == null) if(format == null)
@ -91,9 +96,9 @@ var FormatsSection = React.createClass({
<div> <div>
<h1 style={formatHeaderStyle}>{title}</h1> <h1 style={formatHeaderStyle}>{title}</h1>
{/* In future, anticipate multiple formats, just a guess at what it could look like {/* In future, anticipate multiple formats, just a guess at what it could look like
// var formats = this.props.results.formats // var formats = this.props.claimInfo.formats
// return (<tbody>{formats.map(function(format,i){ */} // return (<tbody>{formats.map(function(format,i){ */}
<FormatItem results={format}/> <FormatItem name={name} claimInfo={format} amount={this.props.amount} />
{/* })}</tbody>); */} {/* })}</tbody>); */}
</div>); </div>);
} }
@ -105,32 +110,39 @@ var DetailPage = React.createClass({
}, },
getInitialState: function() { getInitialState: function() {
return { return {
results: null, claimInfo: null,
amount: null,
searching: true, searching: true,
}; };
}, },
componentWillMount: function() { componentWillMount: function() {
lbry.search(this.props.name, (results) => { lbry.getClaimInfo(this.props.name, (claimInfo) => {
this.setState({ this.setState({
results: results[0], claimInfo: claimInfo.value,
searching: false, searching: false,
}); });
}); });
lbry.getCostEstimate(this.props.name, (amount) => {
this.setState({
amount: amount,
});
});
}, },
render: function() { render: function() {
if (this.state.results == null && this.state.searching) { if (this.state.claimInfo == null && this.state.searching) {
// Still waiting for metadata // Still waiting for metadata
return null; return null;
} }
var name = this.props.name; var name = this.props.name;
var metadata = this.state.metadata; var claimInfo = this.state.claimInfo;
var results = this.state.results; var amount = this.state.amount;
return ( return (
<main className="page"> <main className="page">
<SubPageLogo /> <SubPageLogo />
<FormatsSection name={name} results={results}/> <FormatsSection name={name} claimInfo={claimInfo} amount={amount} />
<section> <section>
<Link href="/" label="<< Return" /> <Link href="/" label="<< Return" />
</section> </section>