From 468692b48040ebd485329e2b17ba422bffba5c38 Mon Sep 17 00:00:00 2001 From: Alex Liebowitz Date: Wed, 23 Nov 2016 23:16:02 -0500 Subject: [PATCH 1/5] Make Download link switch to "Downloading" immediately on click --- js/component/link.js | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/js/component/link.js b/js/component/link.js index 8f9b8cde7..8c1bb3805 100644 --- a/js/component/link.js +++ b/js/component/link.js @@ -103,28 +103,26 @@ var DownloadLink = React.createClass({ }) }, handleClick: function() { - lbry.getCostEstimate(this.props.streamName, (amount) => { - lbry.getBalance((balance) => { - if (amount > balance) { - this.setState({ - modal: 'notEnoughCredits', - }); - } else { - this.startDownload(); - } - }); - }); - }, - startDownload: function() { if (!this.state.downloading) { //@TODO: Continually update this.state.downloading based on actual status of file this.setState({ downloading: true }); - lbry.getStream(this.props.streamName, (streamInfo) => { - this.setState({ - modal: 'downloadStarted', - filePath: streamInfo.path, + lbry.getCostEstimate(this.props.streamName, (amount) => { + lbry.getBalance((balance) => { + if (amount > balance) { + this.setState({ + modal: 'notEnoughCredits', + downloading: false + }); + } else { + lbry.getStream(this.props.streamName, (streamInfo) => { + this.setState({ + modal: 'downloadStarted', + filePath: streamInfo.path, + }); + }); + } }); }); } From 12afb10cbc905b650590a6a18cbcc509eba14f6e Mon Sep 17 00:00:00 2001 From: Alex Liebowitz Date: Wed, 23 Nov 2016 23:19:06 -0500 Subject: [PATCH 2/5] In DownloadLink, don't check this.state.downloading on click If this.state.downloading is true, the button will be disabled anyway. --- js/component/link.js | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/js/component/link.js b/js/component/link.js index 8c1bb3805..7d08cc173 100644 --- a/js/component/link.js +++ b/js/component/link.js @@ -103,29 +103,27 @@ var DownloadLink = React.createClass({ }) }, handleClick: function() { - if (!this.state.downloading) { //@TODO: Continually update this.state.downloading based on actual status of file - this.setState({ - downloading: true - }); + this.setState({ + downloading: true + }); - lbry.getCostEstimate(this.props.streamName, (amount) => { - lbry.getBalance((balance) => { - if (amount > balance) { + lbry.getCostEstimate(this.props.streamName, (amount) => { + lbry.getBalance((balance) => { + if (amount > balance) { + this.setState({ + modal: 'notEnoughCredits', + downloading: false + }); + } else { + lbry.getStream(this.props.streamName, (streamInfo) => { this.setState({ - modal: 'notEnoughCredits', - downloading: false + modal: 'downloadStarted', + filePath: streamInfo.path, }); - } else { - lbry.getStream(this.props.streamName, (streamInfo) => { - this.setState({ - modal: 'downloadStarted', - filePath: streamInfo.path, - }); - }); - } - }); + }); + } }); - } + }); }, render: function() { var label = (!this.state.downloading ? this.props.label : this.props.downloadingLabel); From 323cedadb203450949abe507c8a9393464050dea Mon Sep 17 00:00:00 2001 From: Alex Liebowitz Date: Wed, 23 Nov 2016 23:30:59 -0500 Subject: [PATCH 3/5] Disable Watch link on click --- js/component/link.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/js/component/link.js b/js/component/link.js index 7d08cc173..bc3d12733 100644 --- a/js/component/link.js +++ b/js/component/link.js @@ -152,11 +152,15 @@ var WatchLink = React.createClass({ hidden: React.PropTypes.bool, }, handleClick: function() { + this.setState({ + loading: true, + }) lbry.getCostEstimate(this.props.streamName, (amount) => { lbry.getBalance((balance) => { if (amount > balance) { this.setState({ modal: 'notEnoughCredits', + loading: false, }); } else { window.location = '?watch=' + this.props.streamName; @@ -167,6 +171,7 @@ var WatchLink = React.createClass({ getInitialState: function() { return { modal: null, + loading: false, }; }, closeModal: function() { @@ -184,7 +189,8 @@ var WatchLink = React.createClass({ return ( + disabled={this.state.loading} label={this.props.label} icon={this.props.icon} + onClick={this.handleClick} /> You don't have enough LBRY credits to pay for this stream. From 17d13c3a93b7fc6f61ef9f8599830a58a6608b32 Mon Sep 17 00:00:00 2001 From: Alex Liebowitz Date: Wed, 23 Nov 2016 23:49:19 -0500 Subject: [PATCH 4/5] Properly notify when a download times out --- js/component/link.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/js/component/link.js b/js/component/link.js index bc3d12733..6cd97929c 100644 --- a/js/component/link.js +++ b/js/component/link.js @@ -116,10 +116,17 @@ var DownloadLink = React.createClass({ }); } else { lbry.getStream(this.props.streamName, (streamInfo) => { - this.setState({ - modal: 'downloadStarted', - filePath: streamInfo.path, - }); + if (typeof streamInfo !== 'object') { + this.setState({ + modal: 'timedOut', + downloading: false, + }); + } else { + this.setState({ + modal: 'downloadStarted', + filePath: streamInfo.path, + }); + } }); } }); @@ -137,6 +144,9 @@ var DownloadLink = React.createClass({ You don't have enough LBRY credits to pay for this stream. + + LBRY was unable to download the stream lbry://{this.props.streamName}. + ); } From 7eaeeeefb4c56874683b20983157ef1f9a02edd4 Mon Sep 17 00:00:00 2001 From: Alex Liebowitz Date: Thu, 24 Nov 2016 23:03:03 -0500 Subject: [PATCH 5/5] Wrap modal content in div to prevent flexbox layout --- js/component/modal.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/js/component/modal.js b/js/component/modal.js index b1bb5065f..45362ab1f 100644 --- a/js/component/modal.js +++ b/js/component/modal.js @@ -49,7 +49,9 @@ var Modal = React.createClass({ return ( - {this.props.children} +
+ {this.props.children} +
{buttons}
);