Show: don't display price if file is already downloaded

This commit is contained in:
Alex Liebowitz 2017-04-17 06:03:00 -04:00
parent 94b60beebc
commit bbab1f064a

View file

@ -55,6 +55,7 @@ let ShowPage = React.createClass({
cost: null, cost: null,
costIncludesData: null, costIncludesData: null,
uriLookupComplete: null, uriLookupComplete: null,
isDownloaded: null,
}; };
}, },
componentWillMount: function() { componentWillMount: function() {
@ -62,8 +63,16 @@ let ShowPage = React.createClass({
document.title = this._uri; document.title = this._uri;
lbry.resolve({uri: this._uri}).then(({ claim: {txid, nout, has_signature, signature_is_valid, value: {stream: {metadata, source: {contentType}}}}}) => { lbry.resolve({uri: this._uri}).then(({ claim: {txid, nout, has_signature, signature_is_valid, value: {stream: {metadata, source: {contentType}}}}}) => {
const outpoint = txid + ':' + nout;
lbry.file_list({outpoint}).then((fileInfo) => {
this.setState({
isDownloaded: fileInfo.length > 0,
});
});
this.setState({ this.setState({
outpoint: txid + ':' + nout, outpoint: outpoint,
metadata: metadata, metadata: metadata,
hasSignature: has_signature, hasSignature: has_signature,
signatureIsValid: signature_is_valid, signatureIsValid: signature_is_valid,
@ -80,21 +89,21 @@ let ShowPage = React.createClass({
}); });
}, },
render: function() { render: function() {
const const metadata = this.state.metadata;
metadata = this.state.uriLookupComplete ? this.state.metadata : null, const title = metadata ? this.state.metadata.title : this._uri;
title = this.state.uriLookupComplete ? metadata.title : this._uri;
return ( return (
<main className="constrained-page"> <main className="constrained-page">
<section className="show-page-media"> <section className="show-page-media">
{ this.state.contentType && this.state.contentType.startsWith('video/') ? { this.state.contentType && this.state.contentType.startsWith('video/') ?
<Video className="video-embedded" uri={this._uri} metadata={metadata} /> : <Video className="video-embedded" uri={this._uri} metadata={metadata} outpoint={this.state.outpoint} /> :
(metadata ? <Thumbnail src={metadata.thumbnail} /> : <Thumbnail />) } (metadata ? <Thumbnail src={metadata.thumbnail} /> : <Thumbnail />) }
</section> </section>
<section className="card"> <section className="card">
<div className="card__inner"> <div className="card__inner">
<div className="card__title-identity"> <div className="card__title-identity">
<span style={{float: "right"}}><FilePrice uri={this._uri} metadata={metadata} /></span> {this.state.isDownloaded === false
? <span style={{float: "right"}}><FilePrice uri={this._uri} metadata={this.state.metadata} /></span>
: null}
<h1>{title}</h1> <h1>{title}</h1>
{ this.state.uriLookupComplete ? { this.state.uriLookupComplete ?
<div> <div>