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,28 +103,26 @@ 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.getStream(this.props.streamName, (streamInfo) => {
|
lbry.getCostEstimate(this.props.streamName, (amount) => {
|
||||||
this.setState({
|
lbry.getBalance((balance) => {
|
||||||
modal: 'downloadStarted',
|
if (amount > balance) {
|
||||||
filePath: streamInfo.path,
|
this.setState({
|
||||||
|
modal: 'notEnoughCredits',
|
||||||
|
downloading: false
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
lbry.getStream(this.props.streamName, (streamInfo) => {
|
||||||
|
this.setState({
|
||||||
|
modal: 'downloadStarted',
|
||||||
|
filePath: streamInfo.path,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue