Merge pull request #172 from lbryio/availability-check-fixes
Fix two problems with displaying unavailable files
This commit is contained in:
commit
ab31666f4e
3 changed files with 15 additions and 9 deletions
|
@ -249,13 +249,18 @@ export let FileActions = React.createClass({
|
||||||
this._isMounted = true;
|
this._isMounted = true;
|
||||||
this._fileInfoSubscribeId = lbry.fileInfoSubscribe(this.props.sdHash, this.onFileInfoUpdate);
|
this._fileInfoSubscribeId = lbry.fileInfoSubscribe(this.props.sdHash, this.onFileInfoUpdate);
|
||||||
lbry.getStreamAvailability(this.props.streamName, (availability) => {
|
lbry.getStreamAvailability(this.props.streamName, (availability) => {
|
||||||
if (!this._isMounted) {
|
if (this._isMounted) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
available: availability > 0,
|
available: availability > 0,
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
}, () => {
|
||||||
|
// Take any error to mean the file is unavailable
|
||||||
|
if (this._isMounted) {
|
||||||
|
this.setState({
|
||||||
|
available: false,
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
componentWillUnmount: function() {
|
componentWillUnmount: function() {
|
||||||
|
|
|
@ -177,7 +177,8 @@ export let FileTile = React.createClass({
|
||||||
this._isMounted = true;
|
this._isMounted = true;
|
||||||
|
|
||||||
lbry.resolveName(this.props.name, (metadata) => {
|
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({
|
this.setState({
|
||||||
sdHash: metadata.sources.lbry_sd_hash,
|
sdHash: metadata.sources.lbry_sd_hash,
|
||||||
metadata: metadata,
|
metadata: metadata,
|
||||||
|
|
|
@ -207,8 +207,8 @@ lbry.getPeersForBlobHash = function(blobHash, callback) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
lbry.getStreamAvailability = function(name, callback) {
|
lbry.getStreamAvailability = function(name, callback, errorCallback) {
|
||||||
lbry.call('get_availability', {name: name}, callback);
|
lbry.call('get_availability', {name: name}, callback, errorCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
lbry.getCostInfoForName = function(name, callback, errorCallback) {
|
lbry.getCostInfoForName = function(name, callback, errorCallback) {
|
||||||
|
|
Loading…
Reference in a new issue