Merge branch 'master' into development
This commit is contained in:
commit
a114f81543
3 changed files with 22 additions and 17 deletions
2
dist/requirements.txt
vendored
2
dist/requirements.txt
vendored
|
@ -1 +1 @@
|
||||||
lbrynet>=0.5.0
|
lbrynet>=0.8.4
|
||||||
|
|
|
@ -248,13 +248,13 @@ export let FileActions = React.createClass({
|
||||||
componentDidMount: function() {
|
componentDidMount: function() {
|
||||||
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.getPeersForBlobHash(this.props.sdHash, (peers) => {
|
lbry.getStreamAvailability(this.props.streamName, (availability) => {
|
||||||
if (!this._isMounted) {
|
if (!this._isMounted) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
available: peers.length > 0,
|
available: availability > 0,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
33
js/lbry.js
33
js/lbry.js
|
@ -207,6 +207,10 @@ lbry.getPeersForBlobHash = function(blobHash, callback) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lbry.getStreamAvailability = function(name, callback) {
|
||||||
|
lbry.call('get_availability', {name: name}, callback);
|
||||||
|
}
|
||||||
|
|
||||||
lbry.getCostInfoForName = function(name, callback, errorCallback) {
|
lbry.getCostInfoForName = function(name, callback, errorCallback) {
|
||||||
/**
|
/**
|
||||||
* Takes a LBRY name; will first try and calculate a total cost using
|
* Takes a LBRY name; will first try and calculate a total cost using
|
||||||
|
@ -260,8 +264,8 @@ lbry.getFeaturedDiscoverNames = function(callback) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
lbry.getFileStatus = function(name, callback) {
|
lbry.getFileStatus = function(name, callback, errorCallback) {
|
||||||
lbry.call('get_lbry_file', { 'name': name }, callback);
|
lbry.call('get_lbry_file', { 'name': name }, callback, errorCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
lbry.getFilesInfo = function(callback) {
|
lbry.getFilesInfo = function(callback) {
|
||||||
|
@ -311,22 +315,23 @@ lbry.revealFile = function(sdHash, callback) {
|
||||||
}
|
}
|
||||||
|
|
||||||
lbry.getFileInfoWhenListed = function(name, callback, timeoutCallback, tryNum=0) {
|
lbry.getFileInfoWhenListed = function(name, callback, timeoutCallback, tryNum=0) {
|
||||||
// Calls callback with file info when it appears in the list of files returned by lbry.getFilesInfo().
|
function scheduleNextCheckOrTimeout() {
|
||||||
// If timeoutCallback is provided, it will be called if the file fails to appear.
|
|
||||||
lbry.getFilesInfo(function(fileInfos) {
|
|
||||||
for (var fileInfo of fileInfos) {
|
|
||||||
if (fileInfo.lbry_uri == name) {
|
|
||||||
callback(fileInfo);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (timeoutCallback && tryNum > 200) {
|
if (timeoutCallback && tryNum > 200) {
|
||||||
timeoutCallback();
|
timeoutCallback();
|
||||||
} else {
|
} else {
|
||||||
setTimeout(function() { lbry.getFileInfoWhenListed(name, callback, timeoutCallback, tryNum + 1) }, 250);
|
setTimeout(() => lbry.getFileInfoWhenListed(name, callback, timeoutCallback, tryNum + 1), 250);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
|
// Calls callback with file info when it appears in the lbrynet file manager.
|
||||||
|
// If timeoutCallback is provided, it will be called if the file fails to appear.
|
||||||
|
lbry.getFileStatus(name, (fileInfo) => {
|
||||||
|
if (fileInfo) {
|
||||||
|
callback(fileInfo);
|
||||||
|
} else {
|
||||||
|
scheduleNextCheckOrTimeout();
|
||||||
|
}
|
||||||
|
}, () => scheduleNextCheckOrTimeout());
|
||||||
}
|
}
|
||||||
|
|
||||||
lbry.publish = function(params, fileListedCallback, publishedCallback, errorCallback) {
|
lbry.publish = function(params, fileListedCallback, publishedCallback, errorCallback) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue