From c209c1f84f0fb6082977f4f107d0d3418590a820 Mon Sep 17 00:00:00 2001 From: Alex Liebowitz Date: Fri, 17 Feb 2017 17:26:32 -0500 Subject: [PATCH] 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