diff --git a/js/component/common.js b/js/component/common.js index 40fb0ce7e..a342074c1 100644 --- a/js/component/common.js +++ b/js/component/common.js @@ -124,7 +124,7 @@ export let Thumbnail = React.createClass({ _isMounted: false, propTypes: { - src: React.PropTypes.string.isRequired, + src: React.PropTypes.string, }, handleError: function() { if (this.state.imageUrl != this._defaultImageUri) { diff --git a/js/component/file-actions.js b/js/component/file-actions.js index 0a347bdbc..3d72f31f3 100644 --- a/js/component/file-actions.js +++ b/js/component/file-actions.js @@ -168,7 +168,7 @@ export let FileActions = React.createClass({ componentWillUnmount: function() { this._isMounted = false; if (this._fileInfoSubscribeId) { - lbry.fileInfoUnsubscribe(this.props.name, this._fileInfoSubscribeId); + lbry.fileInfoUnsubscribe(this.props.streamName, this._fileInfoSubscribeId); } }, render: function() { diff --git a/js/component/file-tile.js b/js/component/file-tile.js index 293a63c9c..cf0dff4ee 100644 --- a/js/component/file-tile.js +++ b/js/component/file-tile.js @@ -49,11 +49,10 @@ let FilePrice = React.createClass({ } }); -let FileTile = React.createClass({ - _isMounted: false, - +/*should be merged into FileTile once FileTile is refactored to take a single id*/ +let FileTileStream = React.createClass({ propTypes: { - name: React.PropTypes.string, + metadata: React.PropTypes.object, sdHash: React.PropTypes.string, showPrice: React.PropTypes.bool, obscureNsfw: React.PropTypes.bool, @@ -62,12 +61,11 @@ let FileTile = React.createClass({ getInitialState: function() { return { - metadata: null, - title: null, showNsfwHelp: false, isRemoved: false } }, + getDefaultProps: function() { return { hideOnRemove: false, @@ -76,7 +74,7 @@ let FileTile = React.createClass({ } }, handleMouseOver: function() { - if (this.props.obscureNsfw && this.state.metadata && this.state.metadata.nsfw) { + if (this.props.obscureNsfw && this.props.metadata && this.props.metadata.nsfw) { this.setState({ showNsfwHelp: true, }); @@ -94,34 +92,20 @@ let FileTile = React.createClass({ isRemoved: true, }); }, - componentDidMount: function() { - this._isMounted = true; - - lbry.resolveName(this.props.name, (metadata) => { - if (this._isMounted) { - this.setState({ - metadata: metadata, - title: metadata && metadata.title ? metadata.title : ('lbry://' + this.props.name), - }); - } - }); - }, - componentWillUnmount: function() { - this._isMounted = false; - }, render: function() { - if (this.state.metadata === null || (this.props.hideOnRemove && this.state.isRemoved)) { + if (this.props.metadata === null || (this.props.hideOnRemove && this.state.isRemoved)) { return null; } - const obscureNsfw = this.props.obscureNsfw && this.state.metadata.nsfw; - + const metadata = this.props.metadata || {}, + obscureNsfw = this.props.obscureNsfw && metadata.nsfw, + title = metadata.title ? metadata.title : ('lbry://' + this.props.name); return (
- +
{ this.props.showPrice @@ -131,29 +115,67 @@ let FileTile = React.createClass({

- {this.state.metadata.title} + {title}

- +

- {this.state.metadata.description} + {metadata.description}

{this.state.showNsfwHelp ?
-

- This content is Not Safe For Work. - To view adult content, please change your . -

-
+

+ This content is Not Safe For Work. + To view adult content, please change your . +

+ : null}
); } }); +let FileTile = React.createClass({ + _isMounted: false, + + propTypes: { + name: React.PropTypes.string + }, + + getInitialState: function() { + return { + sdHash: null, + metadata: null + } + }, + + componentDidMount: function() { + this._isMounted = true; + + lbry.resolveName(this.props.name, (metadata) => { + if (this._isMounted) { + this.setState({ + sdHash: metadata.sources.lbry_sd_hash, + metadata: metadata, + }); + } + }); + }, + componentWillUnmount: function() { + this._isMounted = false; + }, + render: function() { + if (this.state.metadata === null || this.state.sdHash === null) { + return null; + } + + return ; + } +}); + export default FileTile; \ No newline at end of file diff --git a/js/lbry.js b/js/lbry.js index 49abcaa95..e826ba023 100644 --- a/js/lbry.js +++ b/js/lbry.js @@ -506,7 +506,7 @@ lbry.fileInfoSubscribeByName = function(name, callback) { // } lbry.fileInfoUnsubscribe = function(name, subscribeId) { - delete lbry._fileInfoSubscribeCallbacks[name][subscribeId]; + lbry._fileInfoSubscribeCallbacks[name] = lbry._fileInfoSubscribeCallbacks[name].splice(subscribeId, 1); } export default lbry; diff --git a/js/page/discover.js b/js/page/discover.js index 873e36f5f..d627df4d3 100644 --- a/js/page/discover.js +++ b/js/page/discover.js @@ -44,7 +44,7 @@ var SearchResults = React.createClass({ var rows = []; this.props.results.forEach(function({name, value}) { rows.push( - + ); }); return (