mirror of
https://github.com/ascribe/onion.git
synced 2024-12-23 01:39:36 +01:00
refactor setState actions to fix overriding values bug
This commit is contained in:
parent
bf6b5e00a6
commit
1c4bf9915c
@ -3,7 +3,7 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
import FileDragAndDropPreview from './file_drag_and_drop_preview';
|
import FileDragAndDropPreview from './file_drag_and_drop_preview';
|
||||||
import FileDragAndDropPreviewProgress from './file_drag_and_drop_preview_progress';
|
//import FileDragAndDropPreviewProgress from './file_drag_and_drop_preview_progress';
|
||||||
|
|
||||||
|
|
||||||
let FileDragAndDropPreviewIterator = React.createClass({
|
let FileDragAndDropPreviewIterator = React.createClass({
|
||||||
|
@ -325,11 +325,9 @@ var ReactS3FineUploader = React.createClass({
|
|||||||
completed: false
|
completed: false
|
||||||
};
|
};
|
||||||
|
|
||||||
let newState = React.addons.update(this.state, {
|
let startedChunks = React.addons.update(this.state.startedChunks, { $set: chunks });
|
||||||
startedChunks: { $set: chunks }
|
|
||||||
});
|
|
||||||
|
|
||||||
this.setState(newState);
|
this.setState({ startedChunks });
|
||||||
},
|
},
|
||||||
|
|
||||||
onUploadChunkSuccess(id, chunkData, responseJson, xhr) {
|
onUploadChunkSuccess(id, chunkData, responseJson, xhr) {
|
||||||
@ -342,11 +340,9 @@ var ReactS3FineUploader = React.createClass({
|
|||||||
chunks[chunkKey].responseJson = responseJson;
|
chunks[chunkKey].responseJson = responseJson;
|
||||||
chunks[chunkKey].xhr = xhr;
|
chunks[chunkKey].xhr = xhr;
|
||||||
|
|
||||||
let newState = React.addons.update(this.state, {
|
let startedChunks = React.addons.update(this.state.startedChunks, { $set: chunks });
|
||||||
startedChunks: { $set: chunks }
|
|
||||||
});
|
|
||||||
|
|
||||||
this.setState(newState);
|
this.setState({ startedChunks });
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
@ -370,11 +366,9 @@ var ReactS3FineUploader = React.createClass({
|
|||||||
files[id].status = 'upload successful';
|
files[id].status = 'upload successful';
|
||||||
files[id].key = this.state.uploader.getKey(id);
|
files[id].key = this.state.uploader.getKey(id);
|
||||||
|
|
||||||
let newState = React.addons.update(this.state, {
|
let filesToUpload = React.addons.update(this.state.filesToUpload, { $set: files });
|
||||||
filesToUpload: { $set: files }
|
|
||||||
});
|
|
||||||
|
|
||||||
this.setState(newState);
|
this.setState({ filesToUpload });
|
||||||
|
|
||||||
// Only after the blob has been created server-side, we can make the form submittable.
|
// Only after the blob has been created server-side, we can make the form submittable.
|
||||||
this.createBlob(files[id])
|
this.createBlob(files[id])
|
||||||
@ -457,15 +451,17 @@ var ReactS3FineUploader = React.createClass({
|
|||||||
} else {
|
} else {
|
||||||
console.warn('You didn\'t define the functions isReadyForFormSubmission and/or setIsUploadReady in as a prop in react-s3-fine-uploader');
|
console.warn('You didn\'t define the functions isReadyForFormSubmission and/or setIsUploadReady in as a prop in react-s3-fine-uploader');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
onProgress(id, name, uploadedBytes, totalBytes) {
|
onProgress(id, name, uploadedBytes, totalBytes) {
|
||||||
let newState = React.addons.update(this.state, {
|
let filesToUpload = React.addons.update(this.state.filesToUpload, {
|
||||||
filesToUpload: { [id]: {
|
[id]: {
|
||||||
progress: { $set: (uploadedBytes / totalBytes) * 100} }
|
progress: { $set: (uploadedBytes / totalBytes) * 100}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.setState(newState);
|
this.setState({ filesToUpload });
|
||||||
},
|
},
|
||||||
|
|
||||||
onSessionRequestComplete(response, success) {
|
onSessionRequestComplete(response, success) {
|
||||||
@ -487,8 +483,9 @@ var ReactS3FineUploader = React.createClass({
|
|||||||
return file;
|
return file;
|
||||||
});
|
});
|
||||||
|
|
||||||
let newState = React.addons.update(this.state, {filesToUpload: {$set: updatedFilesToUpload}});
|
let filesToUpload = React.addons.update(this.state.filesToUpload, {$set: updatedFilesToUpload});
|
||||||
this.setState(newState);
|
|
||||||
|
this.setState({filesToUpload });
|
||||||
} else {
|
} else {
|
||||||
// server has to respond with 204
|
// server has to respond with 204
|
||||||
//let notification = new GlobalNotificationModel('Could not load attached files (Further data)', 'danger', 10000);
|
//let notification = new GlobalNotificationModel('Could not load attached files (Further data)', 'danger', 10000);
|
||||||
@ -758,10 +755,9 @@ var ReactS3FineUploader = React.createClass({
|
|||||||
}
|
}
|
||||||
|
|
||||||
// set the new file array
|
// set the new file array
|
||||||
let newState = React.addons.update(this.state, {
|
let filesToUpload = React.addons.update(this.state.filesToUpload, { $set: oldAndNewFiles });
|
||||||
filesToUpload: { $set: oldAndNewFiles }
|
|
||||||
});
|
this.setState({ filesToUpload });
|
||||||
this.setState(newState);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
setStatusOfFile(fileId, status) {
|
setStatusOfFile(fileId, status) {
|
||||||
@ -773,11 +769,9 @@ var ReactS3FineUploader = React.createClass({
|
|||||||
|
|
||||||
changeSet.status = { $set: status };
|
changeSet.status = { $set: status };
|
||||||
|
|
||||||
let newState = React.addons.update(this.state, {
|
let filesToUpload = React.addons.update(this.state.filesToUpload, { [fileId]: changeSet });
|
||||||
filesToUpload: { [fileId]: changeSet}
|
|
||||||
});
|
|
||||||
|
|
||||||
this.setState(newState);
|
this.setState({ filesToUpload });
|
||||||
},
|
},
|
||||||
|
|
||||||
isDropzoneInactive() {
|
isDropzoneInactive() {
|
||||||
|
Loading…
Reference in New Issue
Block a user