From 5292b069ebda2788376bd8a77f20de8ed2277fd6 Mon Sep 17 00:00:00 2001 From: Alex Liebowitz Date: Wed, 15 Feb 2017 16:46:16 -0500 Subject: [PATCH 01/14] Change Watch page to recognize "paused" status as playable --- js/page/watch.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/page/watch.js b/js/page/watch.js index b145f1a65..a3b1b7f82 100644 --- a/js/page/watch.js +++ b/js/page/watch.js @@ -20,7 +20,7 @@ var WatchPage = React.createClass({ }, updateLoadStatus: function() { lbry.getFileStatus(this.props.name, (status) => { - if (!status || status.code != 'running' || status.written_bytes == 0) { + if (!status || ['running', 'paused'].includes(status.code) || status.written_bytes == 0) { // Download hasn't started yet, so update status message (if available) then try again if (status) { this.setState({ From 77830d1fb235bc551df2eba07a6a53b49460b0cf Mon Sep 17 00:00:00 2001 From: Alex Liebowitz Date: Wed, 15 Feb 2017 16:46:16 -0500 Subject: [PATCH 02/14] Change Watch page to recognize "stopped" status as playable --- js/page/watch.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/page/watch.js b/js/page/watch.js index b145f1a65..24bc1524c 100644 --- a/js/page/watch.js +++ b/js/page/watch.js @@ -20,7 +20,7 @@ var WatchPage = React.createClass({ }, updateLoadStatus: function() { lbry.getFileStatus(this.props.name, (status) => { - if (!status || status.code != 'running' || status.written_bytes == 0) { + if (!status || ['running', 'stopped'].includes(status.code) || status.written_bytes == 0) { // Download hasn't started yet, so update status message (if available) then try again if (status) { this.setState({ From f070baf914f74695fab0673db949eb3ef5df496f Mon Sep 17 00:00:00 2001 From: Alex Liebowitz Date: Wed, 15 Feb 2017 17:24:30 -0500 Subject: [PATCH 03/14] Watch: correct status check to look for "stopped" instead of "paused" --- js/page/watch.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/page/watch.js b/js/page/watch.js index a3b1b7f82..24bc1524c 100644 --- a/js/page/watch.js +++ b/js/page/watch.js @@ -20,7 +20,7 @@ var WatchPage = React.createClass({ }, updateLoadStatus: function() { lbry.getFileStatus(this.props.name, (status) => { - if (!status || ['running', 'paused'].includes(status.code) || status.written_bytes == 0) { + if (!status || ['running', 'stopped'].includes(status.code) || status.written_bytes == 0) { // Download hasn't started yet, so update status message (if available) then try again if (status) { this.setState({ From ee44ce5001dd34be882c34196646936eb1912fc4 Mon Sep 17 00:00:00 2001 From: Alex Liebowitz Date: Thu, 16 Feb 2017 00:19:10 -0500 Subject: [PATCH 04/14] Watch: correct status check logic --- js/page/watch.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/page/watch.js b/js/page/watch.js index 24bc1524c..e9b3a9185 100644 --- a/js/page/watch.js +++ b/js/page/watch.js @@ -20,7 +20,7 @@ var WatchPage = React.createClass({ }, updateLoadStatus: function() { lbry.getFileStatus(this.props.name, (status) => { - if (!status || ['running', 'stopped'].includes(status.code) || status.written_bytes == 0) { + if (!status || !['running', 'stopped'].includes(status.code) || status.written_bytes == 0) { // Download hasn't started yet, so update status message (if available) then try again if (status) { this.setState({ From 38fdcd1e1b7e1b709e8a52068b51d872e3c2ee7a Mon Sep 17 00:00:00 2001 From: Alex Liebowitz Date: Thu, 16 Feb 2017 00:19:10 -0500 Subject: [PATCH 05/14] Watch: correct status check logic --- js/page/watch.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/page/watch.js b/js/page/watch.js index 24bc1524c..e9b3a9185 100644 --- a/js/page/watch.js +++ b/js/page/watch.js @@ -20,7 +20,7 @@ var WatchPage = React.createClass({ }, updateLoadStatus: function() { lbry.getFileStatus(this.props.name, (status) => { - if (!status || ['running', 'stopped'].includes(status.code) || status.written_bytes == 0) { + if (!status || !['running', 'stopped'].includes(status.code) || status.written_bytes == 0) { // Download hasn't started yet, so update status message (if available) then try again if (status) { this.setState({ From 5099fe3ab27ebd8693acdc1709888569e3109753 Mon Sep 17 00:00:00 2001 From: Jeremy Kauffman Date: Thu, 9 Feb 2017 15:53:19 -0500 Subject: [PATCH 06/14] use remote api to fetch featured names --- js/lbry.js | 15 +++++++++++++++ js/page/discover.js | 18 ++++++++++++------ 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/js/lbry.js b/js/lbry.js index 2800bac44..c429d11bf 100644 --- a/js/lbry.js +++ b/js/lbry.js @@ -245,6 +245,21 @@ lbry.getCostInfoForName = function(name, callback, errorCallback) { }); } +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) { lbry.call('get_lbry_file', { 'name': name }, callback); } 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 }) }

From c9a171ae285d5957ba9bd3b1739e82cff42fe800 Mon Sep 17 00:00:00 2001 From: Alex Liebowitz Date: Thu, 16 Feb 2017 20:50:09 -0500 Subject: [PATCH 07/14] Update how Publish page polls for file appearing in file manager Formerly polled the full list of files; now looks up the specific file by name. --- js/lbry.js | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/js/lbry.js b/js/lbry.js index 2800bac44..088bccf9a 100644 --- a/js/lbry.js +++ b/js/lbry.js @@ -245,8 +245,8 @@ lbry.getCostInfoForName = function(name, callback, errorCallback) { }); } -lbry.getFileStatus = function(name, callback) { - lbry.call('get_lbry_file', { 'name': name }, callback); +lbry.getFileStatus = function(name, callback, errorCallback) { + lbry.call('get_lbry_file', { 'name': name }, callback, errorCallback); } lbry.getFilesInfo = function(callback) { @@ -296,22 +296,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) { From fd0439bf0b4a84c7f80334d7571a4db5211e9bfd Mon Sep 17 00:00:00 2001 From: Alex Liebowitz Date: Fri, 17 Feb 2017 15:42:57 -0500 Subject: [PATCH 08/14] Update requirements.txt for My Files publish polling changes --- dist/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From c209c1f84f0fb6082977f4f107d0d3418590a820 Mon Sep 17 00:00:00 2001 From: Alex Liebowitz Date: Fri, 17 Feb 2017 17:26:32 -0500 Subject: [PATCH 09/14] Use get_availability to determine stream availability More info than peer_count, and now has built-in timeout --- js/component/file-actions.js | 4 ++-- js/lbry.js | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/js/component/file-actions.js b/js/component/file-actions.js index cc1dba546..b2a8ff790 100644 --- a/js/component/file-actions.js +++ b/js/component/file-actions.js @@ -248,13 +248,13 @@ 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) => { + lbry.getStreamAvailability(this.props.streamName, (availability) => { if (!this._isMounted) { return; } this.setState({ - available: peers.length > 0, + available: availability > 0, }); }); }, diff --git a/js/lbry.js b/js/lbry.js index 088bccf9a..c55927714 100644 --- a/js/lbry.js +++ b/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) { /** * Takes a LBRY name; will first try and calculate a total cost using From 24e43ba42edd9418af5c6fe778b93072ca754ac4 Mon Sep 17 00:00:00 2001 From: Alex Grintsvayg Date: Sat, 18 Feb 2017 09:53:05 -0500 Subject: [PATCH 10/14] Revert "Use get_availability to determine stream availability" This reverts commit c209c1f84f0fb6082977f4f107d0d3418590a820. This commit may have broken downloading/watching by never showing the download button. Let's see if reverting it fixes the issue. --grin --- js/component/file-actions.js | 4 ++-- js/lbry.js | 4 ---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/js/component/file-actions.js b/js/component/file-actions.js index b2a8ff790..cc1dba546 100644 --- a/js/component/file-actions.js +++ b/js/component/file-actions.js @@ -248,13 +248,13 @@ export let FileActions = React.createClass({ componentDidMount: function() { this._isMounted = true; this._fileInfoSubscribeId = lbry.fileInfoSubscribe(this.props.sdHash, this.onFileInfoUpdate); - lbry.getStreamAvailability(this.props.streamName, (availability) => { + lbry.getPeersForBlobHash(this.props.sdHash, (peers) => { if (!this._isMounted) { return; } this.setState({ - available: availability > 0, + available: peers.length > 0, }); }); }, diff --git a/js/lbry.js b/js/lbry.js index c55927714..088bccf9a 100644 --- a/js/lbry.js +++ b/js/lbry.js @@ -207,10 +207,6 @@ lbry.getPeersForBlobHash = function(blobHash, callback) { }); } -lbry.getStreamAvailability = function(name, callback) { - lbry.call('get_availability', {name: name}, callback); -} - lbry.getCostInfoForName = function(name, callback, errorCallback) { /** * Takes a LBRY name; will first try and calculate a total cost using From fbb11d78c78ef76dd51706ec36412aac5c8562b6 Mon Sep 17 00:00:00 2001 From: Alex Grintsvayg Date: Sat, 18 Feb 2017 09:59:13 -0500 Subject: [PATCH 11/14] Revert "Revert "Use get_availability to determine stream availability"" This reverts commit 24e43ba42edd9418af5c6fe778b93072ca754ac4. Ok, that wasn't it. --- js/component/file-actions.js | 4 ++-- js/lbry.js | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/js/component/file-actions.js b/js/component/file-actions.js index cc1dba546..b2a8ff790 100644 --- a/js/component/file-actions.js +++ b/js/component/file-actions.js @@ -248,13 +248,13 @@ 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) => { + lbry.getStreamAvailability(this.props.streamName, (availability) => { if (!this._isMounted) { return; } this.setState({ - available: peers.length > 0, + available: availability > 0, }); }); }, diff --git a/js/lbry.js b/js/lbry.js index 088bccf9a..c55927714 100644 --- a/js/lbry.js +++ b/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) { /** * Takes a LBRY name; will first try and calculate a total cost using From bb26b5372a03a0314c23e2d26a84ff105fa6b070 Mon Sep 17 00:00:00 2001 From: Alex Liebowitz Date: Sun, 19 Feb 2017 18:19:41 -0500 Subject: [PATCH 12/14] If get_availability gives an error, treat the stream as unavailable --- js/component/file-actions.js | 17 +++++++++++------ js/lbry.js | 4 ++-- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/js/component/file-actions.js b/js/component/file-actions.js index b2a8ff790..fd6570e7f 100644 --- a/js/component/file-actions.js +++ b/js/component/file-actions.js @@ -249,13 +249,18 @@ export let FileActions = React.createClass({ this._isMounted = true; this._fileInfoSubscribeId = lbry.fileInfoSubscribe(this.props.sdHash, this.onFileInfoUpdate); lbry.getStreamAvailability(this.props.streamName, (availability) => { - if (!this._isMounted) { - return; + 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: availability > 0, - }); }); }, componentWillUnmount: function() { diff --git a/js/lbry.js b/js/lbry.js index c55927714..7f6f4c1bc 100644 --- a/js/lbry.js +++ b/js/lbry.js @@ -207,8 +207,8 @@ lbry.getPeersForBlobHash = function(blobHash, callback) { }); } -lbry.getStreamAvailability = function(name, callback) { - lbry.call('get_availability', {name: name}, callback); +lbry.getStreamAvailability = function(name, callback, errorCallback) { + lbry.call('get_availability', {name: name}, callback, errorCallback); } lbry.getCostInfoForName = function(name, callback, errorCallback) { From 1f4ec440df93b5413b84516d3997c2bc1e15aca5 Mon Sep 17 00:00:00 2001 From: Alex Liebowitz Date: Sun, 19 Feb 2017 18:45:03 -0500 Subject: [PATCH 13/14] Fix error in FileTile when metadata is unavailable --- js/component/file-tile.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/js/component/file-tile.js b/js/component/file-tile.js index 2e9e247cd..6cc2afddc 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, From c12ae58089e1d69d668cbaf5e18778bc1e219a78 Mon Sep 17 00:00:00 2001 From: Alex Liebowitz Date: Mon, 20 Feb 2017 22:30:16 -0500 Subject: [PATCH 14/14] Add explanation of version format to CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a8750713..79341d400 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,6 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/). -(Note for Alex: fill in what kind of versioning we want to use) +The LBRY Web UI comes bundled as part of [LBRY App](https://github.com/lbryio/lbry-app). Web UI version numbers should always match the corresponding version of LBRY App. ## [Unreleased]