diff --git a/js/component/file-tile.js b/js/component/file-tile.js index 27b65c691..42f79d16c 100644 --- a/js/component/file-tile.js +++ b/js/component/file-tile.js @@ -51,16 +51,20 @@ let FilePrice = React.createClass({ /*should be merged into FileTile once FileTile is refactored to take a single id*/ export let FileTileStream = React.createClass({ + _fileInfoSubscribeId: null, + _isMounted: null, + propTypes: { metadata: React.PropTypes.object, sdHash: React.PropTypes.string, + hideOnRemove: React.PropTypes.bool, hidePrice: React.PropTypes.bool, obscureNsfw: React.PropTypes.bool }, getInitialState: function() { return { showNsfwHelp: false, - isRemoved: false + isHidden: false } }, getDefaultProps: function() { @@ -69,6 +73,24 @@ export let FileTileStream = React.createClass({ hidePrice: false } }, + componentDidMount: function() { + this._isMounted = true; + if (this.props.hideOnRemove) { + lbry.fileInfoSubscribe(this.props.sdHash, this.onFileInfoUpdate); + } + }, + componentWillUnmount: function() { + if (this._fileInfoSubscribeId) { + lbry.fileInfoUnsubscribe(this.props.sdHash, this._fileInfoSubscribeId); + } + }, + onFileInfoUpdate: function(fileInfo) { + if (!fileInfo && this._isMounted && this.props.hideOnRemove) { + this.setState({ + isHidden: true + }); + } + }, handleMouseOver: function() { if (this.props.obscureNsfw && this.props.metadata && this.props.metadata.nsfw) { this.setState({ @@ -84,6 +106,10 @@ export let FileTileStream = React.createClass({ } }, render: function() { + if (this.state.isHidden) { + return null; + } + const metadata = this.props.metadata || {}, obscureNsfw = this.props.obscureNsfw && metadata.nsfw, title = metadata.title ? metadata.title : ('lbry://' + this.props.name); diff --git a/js/lbry.js b/js/lbry.js index 925f13b34..d264b1a31 100644 --- a/js/lbry.js +++ b/js/lbry.js @@ -463,7 +463,6 @@ lbry._fileInfoSubscribeCallbacks = {}; lbry._fileInfoSubscribeInterval = 5000; lbry._claimIdOwnershipCache = {}; // should be claimId!!! But not - lbry._updateClaimOwnershipCache = function(claimId) { lbry.getMyClaims((claimsInfo) => { lbry._claimIdOwnershipCache[claimId] = !!claimsInfo.reduce(function(match, claimInfo) {