diff --git a/CHANGELOG.md b/CHANGELOG.md index 1cd70fe77..6b0776f00 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/dist/requirements.txt b/dist/requirements.txt index 76861c053..5d8d2b558 100644 --- a/dist/requirements.txt +++ b/dist/requirements.txt @@ -1 +1 @@ -lbrynet>=0.5.0 +lbrynet>=0.8.4 diff --git a/js/component/file-actions.js b/js/component/file-actions.js index cc1dba546..fd6570e7f 100644 --- a/js/component/file-actions.js +++ b/js/component/file-actions.js @@ -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() { diff --git a/js/component/file-tile.js b/js/component/file-tile.js index 7577b1c2a..d6e79b860 100644 --- a/js/component/file-tile.js +++ b/js/component/file-tile.js @@ -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, diff --git a/js/lbry.js b/js/lbry.js index 2800bac44..f594df25a 100644 --- a/js/lbry.js +++ b/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) { diff --git a/js/page/discover.js b/js/page/discover.js index 64246afad..e7a722c47 100644 --- a/js/page/discover.js +++ b/js/page/discover.js @@ -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 (

Featured Content

- - - - - - + { this.state.featuredNames.map((name) => { return }) }