Merge branch 'development' into electron

This commit is contained in:
Alex Liebowitz 2017-02-20 22:56:25 -05:00
commit ae9e474fdc
6 changed files with 62 additions and 30 deletions

View file

@ -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 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] ## [Unreleased]
### Changed ### Changed

View file

@ -1 +1 @@
lbrynet>=0.5.0 lbrynet>=0.8.4

View file

@ -248,14 +248,19 @@ 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;
}
this.setState({ this.setState({
available: peers.length > 0, available: availability > 0,
}); });
}
}, () => {
// Take any error to mean the file is unavailable
if (this._isMounted) {
this.setState({
available: false,
});
}
}); });
}, },
componentWillUnmount: function() { componentWillUnmount: function() {

View file

@ -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,

View file

@ -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) { 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
@ -245,8 +249,23 @@ lbry.getCostInfoForName = function(name, callback, errorCallback) {
}); });
} }
lbry.getFileStatus = function(name, callback) { lbry.getFeaturedDiscoverNames = function(callback) {
lbry.call('get_lbry_file', { 'name': name }, 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) { lbry.getFilesInfo = function(callback) {
@ -296,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) {

View file

@ -65,20 +65,26 @@ var featuredContentLegendStyle = {
}; };
var FeaturedContent = React.createClass({ var FeaturedContent = React.createClass({
getInitialState: function() {
return {
featuredNames: [],
};
},
componentWillMount: function() {
lbry.getFeaturedDiscoverNames().then((featuredNames) => {
this.setState({ featuredNames: featuredNames });
});
},
render: function() { render: function() {
const toolTipText = ('Community Content is a public space where anyone can share content with the ' + 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 ' + 'rest of the LBRY community. Bid on the names "one," "two," "three," "four" and ' +
'"five" to put your content here!'); '"five" to put your content here!');
return ( return (
<div className="row-fluid"> <div className="row-fluid">
<div className="span6"> <div className="span6">
<h3>Featured Content</h3> <h3>Featured Content</h3>
<FileTile name="coherence" /> { this.state.featuredNames.map((name) => { return <FileTile key={name} name={name} /> }) }
<FileTile name="itsadisaster" />
<FileTile name="mikehill-blockbuster" />
<FileTile name="bellflower" />
<FileTile name="cinemasix" />
</div> </div>
<div className="span6"> <div className="span6">
<h3> <h3>