diff --git a/js/component/form.js b/js/component/form.js index ae4135a29..1d2b63bf6 100644 --- a/js/component/form.js +++ b/js/component/form.js @@ -56,6 +56,9 @@ var FormField = React.createClass({ getValue: function() { if (this.props.type == 'checkbox') { return this.refs.field.checked; + } + else if (this.props.type == 'file') { + return this.refs.field.files[0].path; } else { return this.refs.field.value; } diff --git a/js/page/publish.js b/js/page/publish.js index d1d48bc3a..cf2d6f45d 100644 --- a/js/page/publish.js +++ b/js/page/publish.js @@ -45,14 +45,7 @@ var PublishPage = React.createClass({ } } - let fileProcessing = false; - if (this.state.fileInfo && !this.state.tempFileReady) { - this.refs.file.showAdvice('Your file is still processing.'); - this.refs.file.focus(); - fileProcessing = true; - } - - if (missingFieldFound || fileProcessing) { + if (missingFieldFound) { this.setState({ submitting: false, }); @@ -89,7 +82,7 @@ var PublishPage = React.createClass({ }; if (this.refs.file.getValue() !== '') { - publishArgs.file_path = this._tempFilePath; + publishArgs.file_path = this.refs.file.getValue(); } lbry.publish(publishArgs, (message) => { @@ -114,8 +107,6 @@ var PublishPage = React.createClass({ } }, getInitialState: function() { - this._tempFilePath = null; - return { rawName: '', name: '', @@ -127,14 +118,12 @@ var PublishPage = React.createClass({ myClaimValue: 0.0, myClaimMetadata: null, myClaimExists: null, - fileInfo: null, copyrightNotice: '', otherLicenseDescription: '', otherLicenseUrl: '', uploadProgress: 0.0, uploaded: false, errorMessage: null, - tempFileReady: false, submitting: false, modal: null, }; @@ -236,56 +225,6 @@ var PublishPage = React.createClass({ feeCurrency: event.target.value, }); }, - handleFileChange: function(event) { - event.preventDefault(); - - var fileInput = event.target; - - this._tempFilePath = null; - if (fileInput.files.length == 0) { - // File was removed - this.setState({ - fileInfo: null, - uploadProgress: 0.0, - uploaded: false, - tempFileReady: false, - }); - } else { - var file = fileInput.files[0]; - this.setState({ - fileInfo: { - name: file.name, - size: file.size, - }, - uploadProgress: 0.0, - uploaded: false, - tempFileReady: false, - }); - - var xhr = new XMLHttpRequest(); - xhr.upload.addEventListener('progress', (event) => { - this.setState({ - uploadProgress: (event.loaded / event.total), - }); - }); - xhr.upload.addEventListener('load', (event) => { - this.setState({ - uploaded: true, - }); - }); - xhr.addEventListener('load', (event) => { - this._tempFilePath = JSON.parse(xhr.responseText); - this.setState({ - tempFileReady: true, - }); - }) - - var formData = new FormData(fileInput.form); - formData.append('file', fileInput.files[0]); - xhr.open('POST', lbry.webUiUri + '/upload', true); - xhr.send(formData); - } - }, handleFeePrefChange: function(feeEnabled) { this.setState({ isFee: feeEnabled @@ -333,21 +272,6 @@ var PublishPage = React.createClass({ document.title = "Publish"; }, componentDidUpdate: function() { - if (this.state.fileInfo && !this.state.tempFileReady) { - // A file was chosen but the daemon hasn't finished processing it yet, i.e. it's loading, so - // we're displaying a progress bar and need a value for it. - - // React can't unset the "value" prop (to show an "indeterminate" bar) after it's already - // been set, so we have to manage it manually. - - if (!this.state.uploaded) { - // Still uploading - this.refs.progress.setAttribute('value', this.state.uploadProgress); - } else { - // Fully uploaded and waiting for server to finish processing, so set progress bar to "indeterminite" - this.refs.progress.removeAttribute('value'); - } - } }, // Also getting a type warning here too render: function() { @@ -370,13 +294,7 @@ var PublishPage = React.createClass({

Choose File

- - { !this.state.fileInfo ? '' : - (!this.state.tempFileReady ?
- - {!this.state.uploaded ? Importing file into LBRY... : Processing file...} -
- :
File ready for publishing!
) } + { this.state.myClaimExists ?
If you don't choose a file, the file from your existing claim will be used.
: null }