From 9532f8b29a69dea508685c93fbde0383e94140f6 Mon Sep 17 00:00:00 2001 From: Alex Liebowitz Date: Fri, 14 Apr 2017 13:44:06 -0400 Subject: [PATCH] Publish: improve state management of names Save the new name as soon as it's entered instead of after resolution, so that it's possible to publish before the results from resolve() and claim_list_mine() come back. --- ui/js/page/publish.js | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/ui/js/page/publish.js b/ui/js/page/publish.js index 0e6c0478c..ea3bdb00e 100644 --- a/ui/js/page/publish.js +++ b/ui/js/page/publish.js @@ -140,11 +140,11 @@ var PublishPage = React.createClass({ channel: 'anonymous', newChannelName: '@', newChannelBid: 10, - nameResolved: false, + nameResolved: null, + myClaimExists: null, topClaimValue: 0.0, myClaimValue: 0.0, myClaimMetadata: null, - myClaimExists: null, copyrightNotice: '', otherLicenseDescription: '', otherLicenseUrl: '', @@ -189,31 +189,35 @@ var PublishPage = React.createClass({ return; } + const name = rawName.toLowerCase(); this.setState({ rawName: rawName, + name: name, + nameResolved: null, + myClaimExists: null, }); - const name = rawName.toLowerCase(); lbry.getMyClaim(name, (myClaimInfo) => { - if (name != this.refs.name.getValue().toLowerCase()) { + if (name != this.state.name) { // A new name has been typed already, so bail return; } + + this.setState({ + myClaimExists: !!myClaimInfo, + }); lbry.resolve({uri: name}).then((claimInfo) => { - if (name != this.refs.name.getValue()) { + if (name != this.state.name) { return; } if (!claimInfo) { this.setState({ - name: name, nameResolved: false, - myClaimExists: false, }); } else { const topClaimIsMine = (myClaimInfo && myClaimInfo.claim.amount >= claimInfo.claim.amount); const newState = { - name: name, nameResolved: true, topClaimValue: parseFloat(claimInfo.claim.amount), myClaimExists: !!myClaimInfo, @@ -374,13 +378,13 @@ var PublishPage = React.createClass({ getNameBidHelpText: function() { if (!this.state.name) { return "Select a URL for this publish."; - } else if (!this.state.nameResolved) { + } else if (this.state.nameResolved === false) { return "This URL is unused."; } else if (this.state.myClaimExists) { return "You have already used this URL. Publishing to it again will update your previous publish." } else if (this.state.topClaimValue) { return A deposit of at least {this.state.topClaimValue} {this.state.topClaimValue == 1 ? 'credit ' : 'credits '} - is required to win {this.state.name}. However, you can still get a perminent URL for any amount. + is required to win {this.state.name}. However, you can still get a permanent URL for any amount. } else { return ''; } @@ -447,7 +451,7 @@ var PublishPage = React.createClass({

Access

- How much does this content cost ? + How much does this content cost?