Merge pull request #172 from lbryio/availability-check-fixes

Fix two problems with displaying unavailable files
This commit is contained in:
alexliebowitz 2017-02-19 18:49:09 -05:00 committed by GitHub
commit ab31666f4e
3 changed files with 15 additions and 9 deletions

View file

@ -249,13 +249,18 @@ export let FileActions = React.createClass({
this._isMounted = true;
this._fileInfoSubscribeId = lbry.fileInfoSubscribe(this.props.sdHash, this.onFileInfoUpdate);
lbry.getStreamAvailability(this.props.streamName, (availability) => {
if (!this._isMounted) {
return;
}
if (this._isMounted) {
this.setState({
available: availability > 0,
});
}
}, () => {
// Take any error to mean the file is unavailable
if (this._isMounted) {
this.setState({
available: false,
});
}
});
},
componentWillUnmount: function() {

View file

@ -177,7 +177,8 @@ export let FileTile = React.createClass({
this._isMounted = true;
lbry.resolveName(this.props.name, (metadata) => {
if (this._isMounted) {
if (this._isMounted && metadata) {
// In case of a failed lookup, metadata will be null, in which case the component will never display
this.setState({
sdHash: metadata.sources.lbry_sd_hash,
metadata: metadata,

View file

@ -207,8 +207,8 @@ lbry.getPeersForBlobHash = function(blobHash, callback) {
});
}
lbry.getStreamAvailability = function(name, callback) {
lbry.call('get_availability', {name: name}, callback);
lbry.getStreamAvailability = function(name, callback, errorCallback) {
lbry.call('get_availability', {name: name}, callback, errorCallback);
}
lbry.getCostInfoForName = function(name, callback, errorCallback) {