From 5a60cb451c87eea790dcf90348dbf0d8aefccc16 Mon Sep 17 00:00:00 2001 From: Alex Liebowitz Date: Sat, 17 Sep 2016 01:45:42 -0400 Subject: [PATCH 1/3] 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.)) }
From 3b0d24d4f521fe173fbf543ce10de3d6aa083e8f Mon Sep 17 00:00:00 2001 From: Alex Liebowitz Date: Sun, 25 Sep 2016 01:31:58 -0400 Subject: [PATCH 2/3] Bold claim name everywhere on Publish page --- js/page/publish.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/page/publish.js b/js/page/publish.js index f518aca39..f5181c85f 100644 --- a/js/page/publish.js +++ b/js/page/publish.js @@ -328,7 +328,7 @@ var PublishPage = React.createClass({ (!this.state.name ? '' : (! this.state.nameResolved ? The name {this.state.name} is available. : (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.))) + : 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?
From 39dc23398ecdf6a4ac5c6ff3d76dcd25850787c3 Mon Sep 17 00:00:00 2001 From: Alex Liebowitz Date: Sun, 25 Sep 2016 01:34:52 -0400 Subject: [PATCH 3/3] Use global search for filtering special chars in lbry.formatName() --- js/lbry.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/lbry.js b/js/lbry.js index cf3e88770..d1216b6f1 100644 --- a/js/lbry.js +++ b/js/lbry.js @@ -296,7 +296,7 @@ lbry.formatCredits = function(amount, precision) lbry.formatName = function(name) { // Converts LBRY name to standard format (all lower case, no special characters) - return name.toLowerCase().replace(/[^a-z0-9\-]/, ''); + return name.toLowerCase().replace(/[^a-z0-9\-]/g, ''); } lbry.loadJs = function(src, type, onload)