shitty file remove

This commit is contained in:
Jeremy Kauffman 2017-01-13 17:47:48 -05:00 committed by Alex Liebowitz
parent 7f135275df
commit 70db4c937e
2 changed files with 27 additions and 2 deletions

View file

@ -51,16 +51,20 @@ let FilePrice = React.createClass({
/*should be merged into FileTile once FileTile is refactored to take a single id*/ /*should be merged into FileTile once FileTile is refactored to take a single id*/
export let FileTileStream = React.createClass({ export let FileTileStream = React.createClass({
_fileInfoSubscribeId: null,
_isMounted: null,
propTypes: { propTypes: {
metadata: React.PropTypes.object, metadata: React.PropTypes.object,
sdHash: React.PropTypes.string, sdHash: React.PropTypes.string,
hideOnRemove: React.PropTypes.bool,
hidePrice: React.PropTypes.bool, hidePrice: React.PropTypes.bool,
obscureNsfw: React.PropTypes.bool obscureNsfw: React.PropTypes.bool
}, },
getInitialState: function() { getInitialState: function() {
return { return {
showNsfwHelp: false, showNsfwHelp: false,
isRemoved: false isHidden: false
} }
}, },
getDefaultProps: function() { getDefaultProps: function() {
@ -69,6 +73,24 @@ export let FileTileStream = React.createClass({
hidePrice: false 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() { handleMouseOver: function() {
if (this.props.obscureNsfw && this.props.metadata && this.props.metadata.nsfw) { if (this.props.obscureNsfw && this.props.metadata && this.props.metadata.nsfw) {
this.setState({ this.setState({
@ -84,6 +106,10 @@ export let FileTileStream = React.createClass({
} }
}, },
render: function() { render: function() {
if (this.state.isHidden) {
return null;
}
const metadata = this.props.metadata || {}, const metadata = this.props.metadata || {},
obscureNsfw = this.props.obscureNsfw && metadata.nsfw, obscureNsfw = this.props.obscureNsfw && metadata.nsfw,
title = metadata.title ? metadata.title : ('lbry://' + this.props.name); title = metadata.title ? metadata.title : ('lbry://' + this.props.name);

View file

@ -463,7 +463,6 @@ lbry._fileInfoSubscribeCallbacks = {};
lbry._fileInfoSubscribeInterval = 5000; lbry._fileInfoSubscribeInterval = 5000;
lbry._claimIdOwnershipCache = {}; // should be claimId!!! But not lbry._claimIdOwnershipCache = {}; // should be claimId!!! But not
lbry._updateClaimOwnershipCache = function(claimId) { lbry._updateClaimOwnershipCache = function(claimId) {
lbry.getMyClaims((claimsInfo) => { lbry.getMyClaims((claimsInfo) => {
lbry._claimIdOwnershipCache[claimId] = !!claimsInfo.reduce(function(match, claimInfo) { lbry._claimIdOwnershipCache[claimId] = !!claimsInfo.reduce(function(match, claimInfo) {