diff --git a/ui/js/component/publishForm/internal/channelSection.jsx b/ui/js/component/publishForm/internal/channelSection.jsx index b9983d537..5f370f939 100644 --- a/ui/js/component/publishForm/internal/channelSection.jsx +++ b/ui/js/component/publishForm/internal/channelSection.jsx @@ -53,11 +53,18 @@ class ChannelSection extends React.PureComponent { } handleCreateChannelClick(event) { + const min = this.minChannelBid(); + if (this.state.newChannelName.length < 5) { this.refs.newChannelName.showError( __("LBRY channel names must be at least 4 characters in length.") ); return; + } else if (this.state.newChannelBid < min) { + this.refs.newChannelName.showError( + __(`The minimum amount is ${min} credits.`) + ); + return; } this.setState({ @@ -88,6 +95,10 @@ class ChannelSection extends React.PureComponent { this.props.createChannel(newChannelName, amount).then(success, failure); } + minChannelBid() { + return 0.000178; + } + render() { const lbcInputHelp = __( "This LBC remains yours and the deposit can be undone at any time." diff --git a/ui/js/component/publishForm/view.jsx b/ui/js/component/publishForm/view.jsx index 1a343b4cb..c331334b3 100644 --- a/ui/js/component/publishForm/view.jsx +++ b/ui/js/component/publishForm/view.jsx @@ -181,6 +181,10 @@ class PublishForm extends React.PureComponent { return !!myClaims.find(claim => claim.name === name); } + minClaimBid() { + return 0.000097; + } + topClaimIsMine() { const myClaimInfo = this.myClaimInfo(); const { claimsByUri } = this.props; @@ -303,8 +307,16 @@ class PublishForm extends React.PureComponent { } handleBidChange(event) { + const value = event.target.value; + const min = this.minClaimBid(); + + if (value < min) { + this.refs.bid.showError(__(`The minimum amount is ${min} credits.`)); + return; + } + this.setState({ - bid: event.target.value, + bid: value, }); } @@ -377,46 +389,6 @@ class PublishForm extends React.PureComponent { }); } - handleCreateChannelClick(event) { - if (this.state.newChannelName.length < 5) { - this.refs.newChannelName.showError( - __("LBRY channel names must be at least 4 characters in length.") - ); - return; - } - - this.setState({ - creatingChannel: true, - }); - - const newChannelName = this.state.newChannelName; - lbry - .channel_new({ - channel_name: newChannelName, - amount: parseFloat(this.state.newChannelBid), - }) - .then( - () => { - setTimeout(() => { - this.setState({ - creatingChannel: false, - }); - - this._updateChannelList(newChannelName); - }, 10000); - }, - error => { - // TODO: better error handling - this.refs.newChannelName.showError( - __("Unable to create channel due to an internal error.") - ); - this.setState({ - creatingChannel: false, - }); - } - ); - } - getLicense() { switch (this.state.licenseType) { case "copyright": @@ -826,6 +798,7 @@ class PublishForm extends React.PureComponent { ref="bid" type="number" step="0.01" + min="0" label={__("Deposit")} postfix="LBC" onChange={event => {