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.
This commit is contained in:
parent
d926967e49
commit
9532f8b29a
1 changed files with 15 additions and 11 deletions
|
@ -140,11 +140,11 @@ var PublishPage = React.createClass({
|
||||||
channel: 'anonymous',
|
channel: 'anonymous',
|
||||||
newChannelName: '@',
|
newChannelName: '@',
|
||||||
newChannelBid: 10,
|
newChannelBid: 10,
|
||||||
nameResolved: false,
|
nameResolved: null,
|
||||||
|
myClaimExists: null,
|
||||||
topClaimValue: 0.0,
|
topClaimValue: 0.0,
|
||||||
myClaimValue: 0.0,
|
myClaimValue: 0.0,
|
||||||
myClaimMetadata: null,
|
myClaimMetadata: null,
|
||||||
myClaimExists: null,
|
|
||||||
copyrightNotice: '',
|
copyrightNotice: '',
|
||||||
otherLicenseDescription: '',
|
otherLicenseDescription: '',
|
||||||
otherLicenseUrl: '',
|
otherLicenseUrl: '',
|
||||||
|
@ -189,31 +189,35 @@ var PublishPage = React.createClass({
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const name = rawName.toLowerCase();
|
||||||
this.setState({
|
this.setState({
|
||||||
rawName: rawName,
|
rawName: rawName,
|
||||||
|
name: name,
|
||||||
|
nameResolved: null,
|
||||||
|
myClaimExists: null,
|
||||||
});
|
});
|
||||||
|
|
||||||
const name = rawName.toLowerCase();
|
|
||||||
lbry.getMyClaim(name, (myClaimInfo) => {
|
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
|
// A new name has been typed already, so bail
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.setState({
|
||||||
|
myClaimExists: !!myClaimInfo,
|
||||||
|
});
|
||||||
lbry.resolve({uri: name}).then((claimInfo) => {
|
lbry.resolve({uri: name}).then((claimInfo) => {
|
||||||
if (name != this.refs.name.getValue()) {
|
if (name != this.state.name) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!claimInfo) {
|
if (!claimInfo) {
|
||||||
this.setState({
|
this.setState({
|
||||||
name: name,
|
|
||||||
nameResolved: false,
|
nameResolved: false,
|
||||||
myClaimExists: false,
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
const topClaimIsMine = (myClaimInfo && myClaimInfo.claim.amount >= claimInfo.claim.amount);
|
const topClaimIsMine = (myClaimInfo && myClaimInfo.claim.amount >= claimInfo.claim.amount);
|
||||||
const newState = {
|
const newState = {
|
||||||
name: name,
|
|
||||||
nameResolved: true,
|
nameResolved: true,
|
||||||
topClaimValue: parseFloat(claimInfo.claim.amount),
|
topClaimValue: parseFloat(claimInfo.claim.amount),
|
||||||
myClaimExists: !!myClaimInfo,
|
myClaimExists: !!myClaimInfo,
|
||||||
|
@ -374,13 +378,13 @@ var PublishPage = React.createClass({
|
||||||
getNameBidHelpText: function() {
|
getNameBidHelpText: function() {
|
||||||
if (!this.state.name) {
|
if (!this.state.name) {
|
||||||
return "Select a URL for this publish.";
|
return "Select a URL for this publish.";
|
||||||
} else if (!this.state.nameResolved) {
|
} else if (this.state.nameResolved === false) {
|
||||||
return "This URL is unused.";
|
return "This URL is unused.";
|
||||||
} else if (this.state.myClaimExists) {
|
} else if (this.state.myClaimExists) {
|
||||||
return "You have already used this URL. Publishing to it again will update your previous publish."
|
return "You have already used this URL. Publishing to it again will update your previous publish."
|
||||||
} else if (this.state.topClaimValue) {
|
} else if (this.state.topClaimValue) {
|
||||||
return <span>A deposit of at least <strong>{this.state.topClaimValue}</strong> {this.state.topClaimValue == 1 ? 'credit ' : 'credits '}
|
return <span>A deposit of at least <strong>{this.state.topClaimValue}</strong> {this.state.topClaimValue == 1 ? 'credit ' : 'credits '}
|
||||||
is required to win <strong>{this.state.name}</strong>. However, you can still get a perminent URL for any amount.</span>
|
is required to win <strong>{this.state.name}</strong>. However, you can still get a permanent URL for any amount.</span>
|
||||||
} else {
|
} else {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue