Show: use new Lighthouse cost reporting

This commit is contained in:
Alex Liebowitz 2016-12-07 19:38:52 -05:00
parent 06de4534cd
commit 8b781694f2

View file

@ -116,30 +116,25 @@ var DetailPage = React.createClass({
return { return {
metadata: null, metadata: null,
cost: null, cost: null,
searching: true, costIncludesData: null,
matchFound: null, nameLookupComplete: null,
}; };
}, },
componentWillMount: function() { componentWillMount: function() {
document.title = 'lbry://' + this.props.name; document.title = 'lbry://' + this.props.name;
lighthouse.search(this.props.name, (results) => { lbry.resolveName(this.props.name, (metadata) => {
var result = results[0]; this.setState({
metadata: metadata,
nameLookupComplete: true,
});
});
if (result.name != this.props.name) { lbry.getCostInfoForName(this.props.name, ({cost, includesData}) => {
this.setState({ this.setState({
searching: false, cost: cost,
matchFound: false, costIncludesData: includesData,
}); });
} else {
this.setState({
cost: result.cost,
costIncludesData: result.costIncludesData,
metadata: result.value,
searching: false,
matchFound: true,
});
}
}); });
}, },
render: function() { render: function() {
@ -155,7 +150,7 @@ var DetailPage = React.createClass({
return ( return (
<main> <main>
<section className="card"> <section className="card">
{this.state.matchFound ? ( {this.state.nameLookupComplete ? (
<FormatsSection name={name} claimInfo={metadata} cost={cost} costIncludesData={costIncludesData} /> <FormatsSection name={name} claimInfo={metadata} cost={cost} costIncludesData={costIncludesData} />
) : ( ) : (
<div> <div>