From 5a60cb451c87eea790dcf90348dbf0d8aefccc16 Mon Sep 17 00:00:00 2001 From: Alex Liebowitz Date: Sat, 17 Sep 2016 01:45:42 -0400 Subject: [PATCH] Give clearer feedback when updating a claim when have a non-winning bid --- js/page/publish.js | 67 ++++++++++++++++++++++++++-------------------- 1 file changed, 38 insertions(+), 29 deletions(-) diff --git a/js/page/publish.js b/js/page/publish.js index 063e52efa..f518aca39 100644 --- a/js/page/publish.js +++ b/js/page/publish.js @@ -18,7 +18,7 @@ var PublishPage = React.createClass({ }); var checkFields = this._requiredFields.slice(); - if (!this.state.nameIsMine) { + if (!this.state.myClaimExists) { checkFields.push('file'); } @@ -43,7 +43,7 @@ var PublishPage = React.createClass({ if (this.state.nameIsMine) { // Pre-populate with existing metadata - var metadata = Object.assign({}, this.state.claimMetadata); + var metadata = Object.assign({}, this.state.myClaimMetadata); if (this.refs.file.getValue() !== '') { delete metadata.sources; } @@ -111,9 +111,10 @@ var PublishPage = React.createClass({ feeAmount: '', feeCurrency: 'USD', nameResolved: false, - nameIsMine: false, - claimValue: 0.0, - claimMetadata: null, + topClaimValue: 0.0, + myClaimValue: 0.0, + myClaimMetadata: null, + myClaimExists: null, fileInfo: null, copyrightNotice: '', otherLicenseDescription: '', @@ -159,27 +160,33 @@ var PublishPage = React.createClass({ nameResolved: false, }); } else { - lbry.getClaimInfo(name, (claimInfo) => { - if (name != this.refs.name.getValue()) { - return; - } + lbry.getMyClaim(name, (myClaimInfo) => { + lbry.getClaimInfo(name, (claimInfo) => { + if (name != this.refs.name.getValue()) { + return; + } - var newState = { - name: name, - nameResolved: true, - nameIsMine: claimInfo.is_mine, - claimValue: parseFloat(claimInfo.amount), - claimMetadata: claimInfo.value, - }; + var topClaimIsMine = (myClaimInfo && myClaimInfo.amount >= claimInfo.amount); - if (claimInfo.is_mine) { - newState.bid = claimInfo.amount; - } else if (this.state.nameIsMine && !claimInfo.name_is_mine) { - // Just changed away from a name we control, so clear pre-fill - newState.bid = ''; - } + var newState = { + name: name, + nameResolved: true, + topClaimValue: parseFloat(claimInfo.amount), + 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.nameResolved ? The name {this.state.name} is available. - : (this.state.nameIsMine ? You already control the name {this.state.name}. You can use this page to update your claim. - : The name {this.state.name} is currently claimed for {lbry.formatCredits(this.state.claimValue)} credits.))) + : (this.state.myClaimExists ? You already have a claim on the name {this.state.name}. You can use this page to update your claim. + : The name {this.state.name} is currently claimed for {lbry.formatCredits(this.state.topClaimValue)} credits.))) }
What LBRY name would you like to claim for this file?
@@ -338,17 +345,19 @@ var PublishPage = React.createClass({ :
File ready for publishing!
) } - { this.state.nameIsMine ?
If you don't choose a file, the file from your existing claim will be used.
: null } + { this.state.myClaimExists ?
If you don't choose a file, the file from your existing claim will be used.
: null }

Bid Amount

- Credits + Credits
How much would you like to bid for this name? { !this.state.nameResolved ? 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. - : (this.state.nameIsMine ? Your current bid is {lbry.formatCredits(this.state.claimValue)} credits. - : You must bid over {lbry.formatCredits(this.state.claimValue)} credits to claim this name.) } + : (this.state.topClaimIsMine ? You currently control this name with a bid of {lbry.formatCredits(this.state.myClaimValue)} credits. + : (this.state.myClaimExists ? You have a non-winning bid on this name for {lbry.formatCredits(this.state.myClaimValue)} credits. + To control this name, you'll need to increase your bid to at least {lbry.formatCredits(this.state.myClaimValue)} credits. + : You must bid over {lbry.formatCredits(this.state.topClaimValue)} credits to claim this name.)) }