Give clearer feedback when updating a claim when have a non-winning bid

This commit is contained in:
Alex Liebowitz 2016-09-17 01:45:42 -04:00
parent c7ab4b9500
commit 5a60cb451c

View file

@ -18,7 +18,7 @@ var PublishPage = React.createClass({
}); });
var checkFields = this._requiredFields.slice(); var checkFields = this._requiredFields.slice();
if (!this.state.nameIsMine) { if (!this.state.myClaimExists) {
checkFields.push('file'); checkFields.push('file');
} }
@ -43,7 +43,7 @@ var PublishPage = React.createClass({
if (this.state.nameIsMine) { if (this.state.nameIsMine) {
// Pre-populate with existing metadata // Pre-populate with existing metadata
var metadata = Object.assign({}, this.state.claimMetadata); var metadata = Object.assign({}, this.state.myClaimMetadata);
if (this.refs.file.getValue() !== '') { if (this.refs.file.getValue() !== '') {
delete metadata.sources; delete metadata.sources;
} }
@ -111,9 +111,10 @@ var PublishPage = React.createClass({
feeAmount: '', feeAmount: '',
feeCurrency: 'USD', feeCurrency: 'USD',
nameResolved: false, nameResolved: false,
nameIsMine: false, topClaimValue: 0.0,
claimValue: 0.0, myClaimValue: 0.0,
claimMetadata: null, myClaimMetadata: null,
myClaimExists: null,
fileInfo: null, fileInfo: null,
copyrightNotice: '', copyrightNotice: '',
otherLicenseDescription: '', otherLicenseDescription: '',
@ -159,27 +160,33 @@ var PublishPage = React.createClass({
nameResolved: false, nameResolved: false,
}); });
} else { } else {
lbry.getClaimInfo(name, (claimInfo) => { lbry.getMyClaim(name, (myClaimInfo) => {
if (name != this.refs.name.getValue()) { lbry.getClaimInfo(name, (claimInfo) => {
return; if (name != this.refs.name.getValue()) {
} return;
}
var newState = { var topClaimIsMine = (myClaimInfo && myClaimInfo.amount >= claimInfo.amount);
name: name,
nameResolved: true,
nameIsMine: claimInfo.is_mine,
claimValue: parseFloat(claimInfo.amount),
claimMetadata: claimInfo.value,
};
if (claimInfo.is_mine) { var newState = {
newState.bid = claimInfo.amount; name: name,
} else if (this.state.nameIsMine && !claimInfo.name_is_mine) { nameResolved: true,
// Just changed away from a name we control, so clear pre-fill topClaimValue: parseFloat(claimInfo.amount),
newState.bid = ''; myClaimExists: !!myClaimInfo,
} myClaimValue: parseFloat(myClaimInfo.amount),
myClaimMetadata: myClaimInfo.value,
topClaimIsMine: topClaimIsMine,
};
this.setState(newState); if (topClaimIsMine) {
newState.bid = myClaimInfo.amount;
} else if (this.state.myClaimMetadata) {
// Just changed away from a name we have a claim on, so clear pre-fill
newState.bid = '';
}
this.setState(newState);
});
}); });
} }
}); });
@ -320,8 +327,8 @@ var PublishPage = React.createClass({
{ {
(!this.state.name ? '' : (!this.state.name ? '' :
(! this.state.nameResolved ? <em> The name <strong>{this.state.name}</strong> is available.</em> (! this.state.nameResolved ? <em> The name <strong>{this.state.name}</strong> is available.</em>
: (this.state.nameIsMine ? <em> You already control the name <strong>{this.state.name}</strong>. You can use this page to update your claim.</em> : (this.state.myClaimExists ? <em> You already have a claim on the name <strong>{this.state.name}</strong>. You can use this page to update your claim.</em>
: <em> The name {this.state.name} is currently claimed for <strong>{lbry.formatCredits(this.state.claimValue)}</strong> credits.</em>))) : <em> The name {this.state.name} is currently claimed for <strong>{lbry.formatCredits(this.state.topClaimValue)}</strong> credits.</em>)))
} }
<div className="help">What LBRY name would you like to claim for this file?</div> <div className="help">What LBRY name would you like to claim for this file?</div>
</div> </div>
@ -338,17 +345,19 @@ var PublishPage = React.createClass({
</div> </div>
: <div>File ready for publishing!</div>) } : <div>File ready for publishing!</div>) }
</form> </form>
{ this.state.nameIsMine ? <div className="help">If you don't choose a file, the file from your existing claim will be used.</div> : null } { this.state.myClaimExists ? <div className="help">If you don't choose a file, the file from your existing claim will be used.</div> : null }
</section> </section>
<section className="card"> <section className="card">
<h4>Bid Amount</h4> <h4>Bid Amount</h4>
<div className="form-row"> <div className="form-row">
Credits <FormField ref="bid" style={publishNumberStyle} type="text" onChange={this.handleBidChange} value={this.state.bid} placeholder={this.state.nameResolved ? lbry.formatCredits(this.state.claimValue + 10) : 100} /> Credits <FormField ref="bid" style={publishNumberStyle} type="text" onChange={this.handleBidChange} value={this.state.bid} placeholder={this.state.nameResolved ? lbry.formatCredits(this.state.topClaimValue + 10) : 100} />
<div className="help">How much would you like to bid for this name? <div className="help">How much would you like to bid for this name?
{ !this.state.nameResolved ? <span> Since this name is not currently resolved, you may bid as low as you want, but higher bids help prevent others from claiming your name.</span> { !this.state.nameResolved ? <span> Since this name is not currently resolved, you may bid as low as you want, but higher bids help prevent others from claiming your name.</span>
: (this.state.nameIsMine ? <span> Your current bid is <strong>{lbry.formatCredits(this.state.claimValue)}</strong> credits.</span> : (this.state.topClaimIsMine ? <span> You currently control this name with a bid of <strong>{lbry.formatCredits(this.state.myClaimValue)}</strong> credits.</span>
: <span> You must bid over <strong>{lbry.formatCredits(this.state.claimValue)}</strong> credits to claim this name.</span>) } : (this.state.myClaimExists ? <span> You have a non-winning bid on this name for <strong>{lbry.formatCredits(this.state.myClaimValue)}</strong> credits.
To control this name, you'll need to increase your bid to at least <strong>{lbry.formatCredits(this.state.myClaimValue)}</strong> credits.</span>
: <span> You must bid over <strong>{lbry.formatCredits(this.state.topClaimValue)}</strong> credits to claim this name.</span>)) }
</div> </div>
</div> </div>
</section> </section>