Merge pull request #794 from lbryio/insufficient-funds-create-channel
Check the users balance before trying to publish/create a channel
This commit is contained in:
commit
776aadc369
4 changed files with 30 additions and 2 deletions
|
@ -66,6 +66,9 @@
|
||||||
"perMachine": true
|
"perMachine": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"scripts": {
|
||||||
|
"start": "./node_modules/.bin/electron src/main"
|
||||||
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"devtron": "^1.4.0",
|
"devtron": "^1.4.0",
|
||||||
"electron": "^1.7.9",
|
"electron": "^1.7.9",
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import PublishForm from "./view";
|
import PublishForm from "./view";
|
||||||
|
import { selectBalance } from "redux/selectors/wallet";
|
||||||
|
|
||||||
export default connect(null, null)(PublishForm);
|
const select = state => ({
|
||||||
|
balance: selectBalance(state),
|
||||||
|
});
|
||||||
|
|
||||||
|
export default connect(select, null)(PublishForm);
|
||||||
|
|
|
@ -48,11 +48,22 @@ class ChannelSection extends React.PureComponent {
|
||||||
|
|
||||||
handleNewChannelBidChange(event) {
|
handleNewChannelBidChange(event) {
|
||||||
this.setState({
|
this.setState({
|
||||||
newChannelBid: event.target.value,
|
newChannelBid: parseFloat(event.target.value),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
handleCreateChannelClick(event) {
|
handleCreateChannelClick(event) {
|
||||||
|
const { balance } = this.props;
|
||||||
|
const { newChannelBid } = this.state;
|
||||||
|
|
||||||
|
if (newChannelBid > balance) {
|
||||||
|
this.refs.newChannelName.showError(
|
||||||
|
__("Unable to create channel due to insufficient funds.")
|
||||||
|
);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
creatingChannel: true,
|
creatingChannel: true,
|
||||||
});
|
});
|
||||||
|
|
|
@ -61,6 +61,15 @@ class PublishForm extends React.PureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
handleSubmit() {
|
handleSubmit() {
|
||||||
|
const { balance } = this.props;
|
||||||
|
const { bid } = this.state;
|
||||||
|
|
||||||
|
if (bid > balance) {
|
||||||
|
this.handlePublishError({ message: "insufficient funds" });
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
submitting: true,
|
submitting: true,
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue