From 5292b069ebda2788376bd8a77f20de8ed2277fd6 Mon Sep 17 00:00:00 2001 From: Alex Liebowitz Date: Wed, 15 Feb 2017 16:46:16 -0500 Subject: [PATCH 1/8] 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 f070baf914f74695fab0673db949eb3ef5df496f Mon Sep 17 00:00:00 2001 From: Alex Liebowitz Date: Wed, 15 Feb 2017 17:24:30 -0500 Subject: [PATCH 2/8] 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 3/8] 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 c9a171ae285d5957ba9bd3b1739e82cff42fe800 Mon Sep 17 00:00:00 2001 From: Alex Liebowitz Date: Thu, 16 Feb 2017 20:50:09 -0500 Subject: [PATCH 4/8] 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 5/8] 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 6/8] 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 7/8] 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 8/8] 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