Check the users balance before trying to publish/create a channel #794

Merged
neb-b merged 2 commits from insufficient-funds-create-channel into master 2017-11-29 21:42:50 +01:00
3 changed files with 27 additions and 2 deletions
Showing only changes of commit c3eaa8c34d - Show all commits

View file

@ -1,5 +1,10 @@
kauffj commented 2017-11-28 22:27:44 +01:00 (Migrated from github.com)
Review

Why format this? Also we should probably trust selector to fallback to 0?

Why format this? Also we should probably trust selector to fallback to 0?
neb-b commented 2017-11-28 22:32:57 +01:00 (Migrated from github.com)
Review

Ignore this for now. Just copy/pasted from somewhere else

Ignore this for now. Just copy/pasted from somewhere else
kauffj commented 2017-11-28 22:27:44 +01:00 (Migrated from github.com)
Review

Why format this? Also we should probably trust selector to fallback to 0?

Why format this? Also we should probably trust selector to fallback to 0?
neb-b commented 2017-11-28 22:32:57 +01:00 (Migrated from github.com)
Review

Ignore this for now. Just copy/pasted from somewhere else

Ignore this for now. Just copy/pasted from somewhere else
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";
kauffj commented 2017-11-28 22:27:44 +01:00 (Migrated from github.com)
Review

Why format this? Also we should probably trust selector to fallback to 0?

Why format this? Also we should probably trust selector to fallback to 0?
neb-b commented 2017-11-28 22:32:57 +01:00 (Migrated from github.com)
Review

Ignore this for now. Just copy/pasted from somewhere else

Ignore this for now. Just copy/pasted from somewhere else
export default connect(null, null)(PublishForm); const select = state => ({
kauffj commented 2017-11-28 22:27:44 +01:00 (Migrated from github.com)
Review

Why format this? Also we should probably trust selector to fallback to 0?

Why format this? Also we should probably trust selector to fallback to 0?
neb-b commented 2017-11-28 22:32:57 +01:00 (Migrated from github.com)
Review

Ignore this for now. Just copy/pasted from somewhere else

Ignore this for now. Just copy/pasted from somewhere else
kauffj commented 2017-11-28 22:27:44 +01:00 (Migrated from github.com)
Review

Why format this? Also we should probably trust selector to fallback to 0?

Why format this? Also we should probably trust selector to fallback to 0?
neb-b commented 2017-11-28 22:32:57 +01:00 (Migrated from github.com)
Review

Ignore this for now. Just copy/pasted from somewhere else

Ignore this for now. Just copy/pasted from somewhere else
balance: selectBalance(state),
kauffj commented 2017-11-28 22:27:44 +01:00 (Migrated from github.com)
Review

Why format this? Also we should probably trust selector to fallback to 0?

Why format this? Also we should probably trust selector to fallback to 0?
neb-b commented 2017-11-28 22:32:57 +01:00 (Migrated from github.com)
Review

Ignore this for now. Just copy/pasted from somewhere else

Ignore this for now. Just copy/pasted from somewhere else
});
kauffj commented 2017-11-28 22:27:44 +01:00 (Migrated from github.com)
Review

Why format this? Also we should probably trust selector to fallback to 0?

Why format this? Also we should probably trust selector to fallback to 0?
neb-b commented 2017-11-28 22:32:57 +01:00 (Migrated from github.com)
Review

Ignore this for now. Just copy/pasted from somewhere else

Ignore this for now. Just copy/pasted from somewhere else
kauffj commented 2017-11-28 22:27:44 +01:00 (Migrated from github.com)
Review

Why format this? Also we should probably trust selector to fallback to 0?

Why format this? Also we should probably trust selector to fallback to 0?
neb-b commented 2017-11-28 22:32:57 +01:00 (Migrated from github.com)
Review

Ignore this for now. Just copy/pasted from somewhere else

Ignore this for now. Just copy/pasted from somewhere else
export default connect(select, null)(PublishForm);
kauffj commented 2017-11-28 22:27:44 +01:00 (Migrated from github.com)
Review

Why format this? Also we should probably trust selector to fallback to 0?

Why format this? Also we should probably trust selector to fallback to 0?
neb-b commented 2017-11-28 22:32:57 +01:00 (Migrated from github.com)
Review

Ignore this for now. Just copy/pasted from somewhere else

Ignore this for now. Just copy/pasted from somewhere else

kauffj commented 2017-11-28 22:27:44 +01:00 (Migrated from github.com)
Review

Why format this? Also we should probably trust selector to fallback to 0?

Why format this? Also we should probably trust selector to fallback to 0?
neb-b commented 2017-11-28 22:32:57 +01:00 (Migrated from github.com)
Review

Ignore this for now. Just copy/pasted from somewhere else

Ignore this for now. Just copy/pasted from somewhere else
kauffj commented 2017-11-28 22:27:44 +01:00 (Migrated from github.com)
Review

Why format this? Also we should probably trust selector to fallback to 0?

Why format this? Also we should probably trust selector to fallback to 0?
neb-b commented 2017-11-28 22:32:57 +01:00 (Migrated from github.com)
Review

Ignore this for now. Just copy/pasted from somewhere else

Ignore this for now. Just copy/pasted from somewhere else

View file

@ -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,
}); });

View file

@ -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,
}); });