From 867803e7c4afe844ffc291ee9294190f31341287 Mon Sep 17 00:00:00 2001 From: Sean Yesmunt Date: Tue, 28 Nov 2017 14:28:34 -0500 Subject: [PATCH 1/2] add start script --- package.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/package.json b/package.json index 3c3bc5a0a..0946afe2c 100644 --- a/package.json +++ b/package.json @@ -66,6 +66,9 @@ "perMachine": true } }, + "scripts": { + "start": "./node_modules/.bin/electron src/main" + }, "devDependencies": { "devtron": "^1.4.0", "electron": "^1.7.9", -- 2.45.2 From c3eaa8c34dea74dc979fa88ec8d3bc6c57a36e50 Mon Sep 17 00:00:00 2001 From: Sean Yesmunt Date: Tue, 28 Nov 2017 23:26:07 -0500 Subject: [PATCH 2/2] check users balance before creating channel/publishing --- src/renderer/js/component/publishForm/index.js | 7 ++++++- .../publishForm/internal/channelSection.jsx | 13 ++++++++++++- src/renderer/js/component/publishForm/view.jsx | 9 +++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/renderer/js/component/publishForm/index.js b/src/renderer/js/component/publishForm/index.js index a55cf9187..df41581d9 100644 --- a/src/renderer/js/component/publishForm/index.js +++ b/src/renderer/js/component/publishForm/index.js @@ -1,5 +1,10 @@ import React from "react"; import { connect } from "react-redux"; 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); diff --git a/src/renderer/js/component/publishForm/internal/channelSection.jsx b/src/renderer/js/component/publishForm/internal/channelSection.jsx index 203e90e74..49c560f65 100644 --- a/src/renderer/js/component/publishForm/internal/channelSection.jsx +++ b/src/renderer/js/component/publishForm/internal/channelSection.jsx @@ -48,11 +48,22 @@ class ChannelSection extends React.PureComponent { handleNewChannelBidChange(event) { this.setState({ - newChannelBid: event.target.value, + newChannelBid: parseFloat(event.target.value), }); } 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({ creatingChannel: true, }); diff --git a/src/renderer/js/component/publishForm/view.jsx b/src/renderer/js/component/publishForm/view.jsx index 75ac22d2b..deb16e248 100644 --- a/src/renderer/js/component/publishForm/view.jsx +++ b/src/renderer/js/component/publishForm/view.jsx @@ -61,6 +61,15 @@ class PublishForm extends React.PureComponent { } handleSubmit() { + const { balance } = this.props; + const { bid } = this.state; + + if (bid > balance) { + this.handlePublishError({ message: "insufficient funds" }); + + return; + } + this.setState({ submitting: true, }); -- 2.45.2