Tab Removal & Check Abstraction

Per Jessop's request: https://github.com/lbryio/spee.ch/pull/1011#pullrequestreview-243975520
Corrected tabs and added the clarified abstraction to the request state check.
This commit is contained in:
ProfessorDey 2019-05-31 00:15:27 +01:00 committed by GitHub
parent 82ab3b47b1
commit 8a6cd2db13
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -22,16 +22,16 @@ export const makePublishRequestChannel = (fd, isUpdate) => {
xhr.upload.addEventListener('load', onLoad); xhr.upload.addEventListener('load', onLoad);
// set state change handler // set state change handler
xhr.onreadystatechange = () => { xhr.onreadystatechange = () => {
if (xhr.readyState === 4) { if (xhr.readyState === XMLHttpRequest.DONE) {
switch (xhr.status) { switch (xhr.status) {
case 413: case 413:
emitter({error: new Error("Unfortunately it appears this web server " + emitter({error: new Error("Unfortunately it appears this web server " +
"has been misconfigured, please inform the service administrators " + "has been misconfigured, please inform the service administrators " +
"that they must set their nginx/apache request size maximums higher " + "that they must set their nginx/apache request size maximums higher " +
"than their file size limits.")}); "than their file size limits.")});
emitter(END); emitter(END);
break; break;
case 200: case 200:
var response = JSON.parse(xhr.response); var response = JSON.parse(xhr.response);
if (response.success) { if (response.success) {
emitter({success: response}); emitter({success: response});
@ -40,12 +40,12 @@ export const makePublishRequestChannel = (fd, isUpdate) => {
emitter({error: new Error(response.message)}); emitter({error: new Error(response.message)});
emitter(END); emitter(END);
} }
break; break;
default: default:
emitter({error: new Error("Received an unexpected response from " + emitter({error: new Error("Received an unexpected response from " +
"server: " + xhr.status)}); "server: " + xhr.status)});
emitter(END); emitter(END);
} }
} }
}; };
// open and send // open and send