diff --git a/ui/js/app.js b/ui/js/app.js index 76ee648bd..735eefea6 100644 --- a/ui/js/app.js +++ b/ui/js/app.js @@ -10,7 +10,7 @@ import StartPage from './page/start.js'; import ClaimCodePage from './page/claim_code.js'; import ReferralPage from './page/referral.js'; import WalletPage from './page/wallet.js'; -import DetailPage from './page/show.js'; +import ShowPage from './page/show.js'; import PublishPage from './page/publish.js'; import DiscoverPage from './page/discover.js'; import SplashScreen from './component/splash.js'; @@ -277,7 +277,7 @@ var App = React.createClass({ case 'receive': return ; case 'show': - return ; + return ; case 'publish': return ; case 'developer': diff --git a/ui/js/page/show.js b/ui/js/page/show.js index 8f4d450c9..49aff7569 100644 --- a/ui/js/page/show.js +++ b/ui/js/page/show.js @@ -1,6 +1,7 @@ import React from 'react'; import lbry from '../lbry.js'; import lighthouse from '../lighthouse.js'; +import uri from '../uri.js'; import {CreditAmount, Thumbnail} from '../component/common.js'; import {FileActions} from '../component/file-actions.js'; import {Link} from '../component/link.js'; @@ -16,22 +17,16 @@ var formatItemImgStyle = { var FormatItem = React.createClass({ propTypes: { - claimInfo: React.PropTypes.object, + metadata: React.PropTypes.object, + contentType: React.PropTypes.string, cost: React.PropTypes.number, - name: React.PropTypes.string, + uri: React.PropTypes.string, outpoint: React.PropTypes.string, costIncludesData: React.PropTypes.bool, }, render: function() { - var claimInfo = this.props.claimInfo; - var thumbnail = claimInfo.thumbnail; - var title = claimInfo.title; - var description = claimInfo.description; - var author = claimInfo.author; - var language = claimInfo.language; - var license = claimInfo.license; - var fileContentType = (claimInfo.content_type || claimInfo['content-type']); - var mediaType = lbry.getMediaType(fileContentType); + const {thumbnail, author, title, description, language, license} = this.props.metadata; + const mediaType = lbry.getMediaType(this.props.contentType); var costIncludesData = this.props.costIncludesData; var cost = this.props.cost || 0.0; @@ -46,7 +41,7 @@ var FormatItem = React.createClass({ - + @@ -63,7 +58,7 @@ var FormatItem = React.createClass({
Content-Type{fileContentType}Content-Type{this.props.contentType}
Cost
- +
@@ -75,17 +70,15 @@ var FormatItem = React.createClass({ var FormatsSection = React.createClass({ propTypes: { - claimInfo: React.PropTypes.object, + uri: React.PropTypes.string, + outpoint: React.PropTypes.string, + metadata: React.PropTypes.object, + contentType: React.PropTypes.string, cost: React.PropTypes.number, - name: React.PropTypes.string, costIncludesData: React.PropTypes.bool, }, render: function() { - var name = this.props.name; - var format = this.props.claimInfo; - var title = format.title; - - if(format == null) + if(this.props.metadata == null) { return (
@@ -95,41 +88,46 @@ var FormatsSection = React.createClass({ return (
-
lbry://{name}
-

{title}

+
{this.props.uri}
+

{this.props.metadata.title}

{/* In future, anticipate multiple formats, just a guess at what it could look like - // var formats = this.props.claimInfo.formats + // var formats = this.props.metadata.formats // return ({formats.map(function(format,i){ */} - + {/* })}); */}
); } }); -var DetailPage = React.createClass({ +var ShowPage = React.createClass({ + _uri: null, + propTypes: { - name: React.PropTypes.string, + uri: React.PropTypes.string, }, getInitialState: function() { return { metadata: null, + contentType: null, cost: null, costIncludesData: null, - nameLookupComplete: null, + uriLookupComplete: null, }; }, componentWillMount: function() { - document.title = 'lbry://' + this.props.name; + this._uri = uri.normalizeLbryUri(this.props.uri); + document.title = this._uri; - lbry.claim_show({name: this.props.name}, ({name, txid, nout, value}) => { + lbry.resolve({uri: this._uri}).then(({txid, nout, claim: {value: {stream: {metadata, source: {contentType}}}}}) => { this.setState({ outpoint: txid + ':' + nout, - metadata: value, - nameLookupComplete: true, + metadata: metadata, + contentType: contentType, + uriLookupComplete: true, }); }); - lbry.getCostInfoForName(this.props.name, ({cost, includesData}) => { + lbry.getCostInfo(this._uri, ({cost, includesData}) => { this.setState({ cost: cost, costIncludesData: includesData, @@ -141,21 +139,15 @@ var DetailPage = React.createClass({ return null; } - const name = this.props.name; - const costIncludesData = this.state.costIncludesData; - const metadata = this.state.metadata; - const cost = this.state.cost; - const outpoint = this.state.outpoint; - return (
- {this.state.nameLookupComplete ? ( - + {this.state.uriLookupComplete ? ( + ) : (

No content

- There is no content available at the name lbry://{this.props.name}. If you reached this page from a link within the LBRY interface, please . Thanks! + There is no content available at {this._uri}. If you reached this page from a link within the LBRY interface, please . Thanks!
)}
@@ -163,4 +155,4 @@ var DetailPage = React.createClass({ } }); -export default DetailPage; +export default ShowPage;