Alert user if they don't have enough credits for watch/download
This commit is contained in:
parent
7b8a4918a1
commit
9a01b7202f
1 changed files with 25 additions and 6 deletions
|
@ -106,6 +106,17 @@ var DownloadLink = React.createClass({
|
||||||
downloading: false,
|
downloading: false,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
handleClick: function() {
|
||||||
|
lbry.getCostEstimate(this.props.streamName, (amount) => {
|
||||||
|
lbry.getBalance((balance) => {
|
||||||
|
if (amount > balance) {
|
||||||
|
alert("You don't have enough LBRY credits to pay for this stream.");
|
||||||
|
} else {
|
||||||
|
this.startDownload();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
startDownload: function() {
|
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({
|
||||||
|
@ -121,7 +132,7 @@ 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);
|
||||||
return <Link button={this.props.button} hidden={this.props.hidden} style={this.props.style}
|
return <Link button={this.props.button} hidden={this.props.hidden} style={this.props.style}
|
||||||
disabled={this.state.downloading} label={label} icon={this.props.icon} onClick={this.startDownload} />;
|
disabled={this.state.downloading} label={label} icon={this.props.icon} onClick={this.handleClick} />;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -134,7 +145,17 @@ var WatchLink = React.createClass({
|
||||||
style: React.PropTypes.object,
|
style: React.PropTypes.object,
|
||||||
hidden: React.PropTypes.bool,
|
hidden: React.PropTypes.bool,
|
||||||
},
|
},
|
||||||
|
handleClick: function() {
|
||||||
|
lbry.getCostEstimate(this.props.streamName, (amount) => {
|
||||||
|
lbry.getBalance((balance) => {
|
||||||
|
if (amount > balance) {
|
||||||
|
alert("You don't have enough LBRY credits to pay for this stream.");
|
||||||
|
} else {
|
||||||
|
window.location = '?watch=' + this.props.streamName;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
getDefaultProps: function() {
|
getDefaultProps: function() {
|
||||||
return {
|
return {
|
||||||
icon: 'icon-play',
|
icon: 'icon-play',
|
||||||
|
@ -143,10 +164,8 @@ var WatchLink = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
var uri = "/?watch=" + this.props.streamName;
|
|
||||||
|
|
||||||
return <Link button={this.props.button} hidden={this.props.hidden} style={this.props.style}
|
return <Link button={this.props.button} hidden={this.props.hidden} style={this.props.style}
|
||||||
href={uri} label={this.props.label} icon={this.props.icon} onClick={this.onClick} />;
|
label={this.props.label} icon={this.props.icon} onClick={this.handleClick} />;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue