Merge branch 'development' into electron
This commit is contained in:
commit
ae9e474fdc
6 changed files with 62 additions and 30 deletions
|
@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file.
|
|||
|
||||
The format is based on [Keep a Changelog](http://keepachangelog.com/).
|
||||
|
||||
The UI versions track the corresponding version in https://github.com/lbryio/lbry
|
||||
The LBRY Web UI comes bundled as part of [LBRY App](https://github.com/lbryio/lbry-app). Web UI version numbers track corresponding version of LBRY App.
|
||||
|
||||
## [Unreleased]
|
||||
### Changed
|
||||
|
|
2
dist/requirements.txt
vendored
2
dist/requirements.txt
vendored
|
@ -1 +1 @@
|
|||
lbrynet>=0.5.0
|
||||
lbrynet>=0.8.4
|
||||
|
|
|
@ -248,14 +248,19 @@ export let FileActions = React.createClass({
|
|||
componentDidMount: function() {
|
||||
this._isMounted = true;
|
||||
this._fileInfoSubscribeId = lbry.fileInfoSubscribe(this.props.sdHash, this.onFileInfoUpdate);
|
||||
lbry.getPeersForBlobHash(this.props.sdHash, (peers) => {
|
||||
if (!this._isMounted) {
|
||||
return;
|
||||
lbry.getStreamAvailability(this.props.streamName, (availability) => {
|
||||
if (this._isMounted) {
|
||||
this.setState({
|
||||
available: availability > 0,
|
||||
});
|
||||
}
|
||||
}, () => {
|
||||
// Take any error to mean the file is unavailable
|
||||
if (this._isMounted) {
|
||||
this.setState({
|
||||
available: false,
|
||||
});
|
||||
}
|
||||
|
||||
this.setState({
|
||||
available: peers.length > 0,
|
||||
});
|
||||
});
|
||||
},
|
||||
componentWillUnmount: function() {
|
||||
|
|
|
@ -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,
|
||||
|
|
48
js/lbry.js
48
js/lbry.js
|
@ -207,6 +207,10 @@ lbry.getPeersForBlobHash = function(blobHash, callback) {
|
|||
});
|
||||
}
|
||||
|
||||
lbry.getStreamAvailability = function(name, callback, errorCallback) {
|
||||
lbry.call('get_availability', {name: name}, callback, errorCallback);
|
||||
}
|
||||
|
||||
lbry.getCostInfoForName = function(name, callback, errorCallback) {
|
||||
/**
|
||||
* Takes a LBRY name; will first try and calculate a total cost using
|
||||
|
@ -245,8 +249,23 @@ lbry.getCostInfoForName = function(name, callback, errorCallback) {
|
|||
});
|
||||
}
|
||||
|
||||
lbry.getFileStatus = function(name, callback) {
|
||||
lbry.call('get_lbry_file', { 'name': name }, callback);
|
||||
lbry.getFeaturedDiscoverNames = function(callback) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
var xhr = new XMLHttpRequest;
|
||||
xhr.open('GET', 'https://api.lbry.io/discover/list', true);
|
||||
xhr.onload = () => {
|
||||
if (xhr.status === 200) {
|
||||
resolve(JSON.parse(xhr.responseText));
|
||||
} else {
|
||||
reject(Error('Failed to fetch featured names.'));
|
||||
}
|
||||
};
|
||||
xhr.send();
|
||||
});
|
||||
}
|
||||
|
||||
lbry.getFileStatus = function(name, callback, errorCallback) {
|
||||
lbry.call('get_lbry_file', { 'name': name }, callback, errorCallback);
|
||||
}
|
||||
|
||||
lbry.getFilesInfo = function(callback) {
|
||||
|
@ -296,22 +315,23 @@ lbry.revealFile = function(sdHash, callback) {
|
|||
}
|
||||
|
||||
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().
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
function scheduleNextCheckOrTimeout() {
|
||||
if (timeoutCallback && tryNum > 200) {
|
||||
timeoutCallback();
|
||||
} 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) {
|
||||
|
|
|
@ -65,20 +65,26 @@ var featuredContentLegendStyle = {
|
|||
};
|
||||
|
||||
var FeaturedContent = React.createClass({
|
||||
getInitialState: function() {
|
||||
return {
|
||||
featuredNames: [],
|
||||
};
|
||||
},
|
||||
componentWillMount: function() {
|
||||
lbry.getFeaturedDiscoverNames().then((featuredNames) => {
|
||||
this.setState({ featuredNames: featuredNames });
|
||||
});
|
||||
},
|
||||
render: function() {
|
||||
const toolTipText = ('Community Content is a public space where anyone can share content with the ' +
|
||||
'rest of the LBRY community. Bid on the names "one," "two," "three," "four" and ' +
|
||||
'"five" to put your content here!');
|
||||
|
||||
return (
|
||||
<div className="row-fluid">
|
||||
<div className="span6">
|
||||
<h3>Featured Content</h3>
|
||||
<FileTile name="coherence" />
|
||||
<FileTile name="itsadisaster" />
|
||||
<FileTile name="mikehill-blockbuster" />
|
||||
<FileTile name="bellflower" />
|
||||
<FileTile name="cinemasix" />
|
||||
|
||||
{ this.state.featuredNames.map((name) => { return <FileTile key={name} name={name} /> }) }
|
||||
</div>
|
||||
<div className="span6">
|
||||
<h3>
|
||||
|
|
Loading…
Reference in a new issue