From 7a5f478b4dbbf0a428552331709c21b4dc131a60 Mon Sep 17 00:00:00 2001 From: Alex Liebowitz Date: Mon, 8 Aug 2016 05:53:41 -0400 Subject: [PATCH 1/2] Change wording on Publish page for claims user already controls --- js/page/publish.js | 54 +++++++++++++++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 17 deletions(-) diff --git a/js/page/publish.js b/js/page/publish.js index 2b84cea78..f0cadd1c3 100644 --- a/js/page/publish.js +++ b/js/page/publish.js @@ -10,15 +10,20 @@ var publishNumberStyle = { }; var PublishPage = React.createClass({ - _requiredFields: ['name', 'file', 'bid', 'meta_title', 'meta_author', 'meta_license', 'meta_description'], + _requiredFields: ['name', 'bid', 'meta_title', 'meta_author', 'meta_license', 'meta_description'], handleSubmit: function() { this.setState({ submitting: true, }); + var checkFields = this._requiredFields.slice(); + if (!this.state.nameIsMine) { + checkFields.push('file'); + } + var missingFieldFound = false; - for (let fieldName of this._requiredFields) { + for (let fieldName of checkFields) { var field = this.refs[fieldName]; if (field.getValue() === '') { field.warnRequired(); @@ -60,17 +65,18 @@ var PublishPage = React.createClass({ } var doPublish = () => { - console.log({name: this.state.name, - file_path: this._tempFilePath, + var publishArgs = { + name: this.state.name, bid: parseFloat(this.state.bid), metadata: metadata, - }); - lbry.publish({ - name: this.refs.name.getValue(), - file_path: this._tempFilePath, - bid: parseFloat(this.state.bid), - metadata: metadata, - }, (message) => { + }; + + if (this.refs.file.getValue() !== '') { + publishArgs.file_path = this._tempFilePath; + } + + console.log(publishArgs); + lbry.publish(publishArgs, (message) => { this.handlePublishSuccess(); this.setState({ submitting: false, @@ -106,6 +112,7 @@ var PublishPage = React.createClass({ feeAmount: '', feeCurrency: 'USD', nameResolved: false, + nameIsMine: false, claimValue: 0.0, fileInfo: null, uploadProgress: 0.0, @@ -143,11 +150,21 @@ var PublishPage = React.createClass({ }); } else { lbry.getClaimInfo(name, (claimInfo) => { - this.setState({ + var newState = { name: name, nameResolved: true, + nameIsMine: claimInfo.is_mine, claimValue: parseFloat(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 = ''; + } + + this.setState(newState); }); } }); @@ -247,8 +264,9 @@ var PublishPage = React.createClass({ lbry:// { (!this.state.name ? '' : - (this.state.nameResolved ? This name is currently claimed for {lbry.formatCredits(this.state.claimValue)} credits - : This name is available)) + (! this.state.nameResolved ? This name is available + : (this.state.nameIsMine ? You already control this name. You can use this page to update your claim. + : This name is currently claimed for {lbry.formatCredits(this.state.claimValue)} credits.))) }
What LBRY name would you like to claim for this file?
@@ -264,6 +282,7 @@ 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 }
@@ -271,7 +290,8 @@ var PublishPage = React.createClass({ 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. - : You must bid over {lbry.formatCredits(this.state.claimValue)} credits to claim this 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.) }
@@ -335,4 +355,4 @@ var PublishPage = React.createClass({ ); } -}); \ No newline at end of file +}); From 6b899bdfc0faf5407dad804b452fbe9ea7f73773 Mon Sep 17 00:00:00 2001 From: Alex Liebowitz Date: Tue, 9 Aug 2016 02:41:57 -0400 Subject: [PATCH 2/2] Pass sources from existing claim to publish() if file not provided --- js/page/publish.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/js/page/publish.js b/js/page/publish.js index f0cadd1c3..e605ae686 100644 --- a/js/page/publish.js +++ b/js/page/publish.js @@ -71,7 +71,9 @@ var PublishPage = React.createClass({ metadata: metadata, }; - if (this.refs.file.getValue() !== '') { + if (this.refs.file.getValue() === '') { + publishArgs.metadata.sources = this.state.claimMetadata.sources; + } else { publishArgs.file_path = this._tempFilePath; } @@ -114,6 +116,7 @@ var PublishPage = React.createClass({ nameResolved: false, nameIsMine: false, claimValue: 0.0, + claimMetadata: null, fileInfo: null, uploadProgress: 0.0, uploaded: false, @@ -153,8 +156,9 @@ var PublishPage = React.createClass({ var newState = { name: name, nameResolved: true, - nameIsMine: claimInfo.is_mine, + nameIsMine: true, //claimInfo.is_mine, claimValue: parseFloat(claimInfo.amount), + claimMetadata: claimInfo.value, }; if (claimInfo.is_mine) {