Make Download link switch to "Downloading" immediately on click
This commit is contained in:
parent
68b377e7a6
commit
468692b480
1 changed files with 15 additions and 17 deletions
|
@ -103,24 +103,19 @@ var DownloadLink = React.createClass({
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
handleClick: function() {
|
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
|
if (!this.state.downloading) { //@TODO: Continually update this.state.downloading based on actual status of file
|
||||||
this.setState({
|
this.setState({
|
||||||
downloading: true
|
downloading: true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
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) => {
|
lbry.getStream(this.props.streamName, (streamInfo) => {
|
||||||
this.setState({
|
this.setState({
|
||||||
modal: 'downloadStarted',
|
modal: 'downloadStarted',
|
||||||
|
@ -128,6 +123,9 @@ var DownloadLink = React.createClass({
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
render: function() {
|
render: function() {
|
||||||
var label = (!this.state.downloading ? this.props.label : this.props.downloadingLabel);
|
var label = (!this.state.downloading ? this.props.label : this.props.downloadingLabel);
|
||||||
|
|
Loading…
Reference in a new issue