From 12afb10cbc905b650590a6a18cbcc509eba14f6e Mon Sep 17 00:00:00 2001 From: Alex Liebowitz Date: Wed, 23 Nov 2016 23:19:06 -0500 Subject: [PATCH] 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);