Show minimum LBC deposit amounts for Publish / Claims

set min bid for channel creation

remove unused function handleCreateChannelClick

lbryio/lbry-app#440

display claim min-bid

get bids from function

add better message error

prevent negative value in WalletSend > input
This commit is contained in:
Baltazar Gomez 2017-08-05 09:53:47 -06:00 committed by Jeremy Kauffman
parent 91c041cfd8
commit eac8b345d9
2 changed files with 25 additions and 41 deletions

View file

@ -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."

View file

@ -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 => {