summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--webapp/components/create_post.jsx14
-rw-r--r--webapp/components/file_upload.jsx8
2 files changed, 13 insertions, 9 deletions
diff --git a/webapp/components/create_post.jsx b/webapp/components/create_post.jsx
index 9bbc44f38..011e0c2b8 100644
--- a/webapp/components/create_post.jsx
+++ b/webapp/components/create_post.jsx
@@ -253,9 +253,11 @@ class CreatePost extends React.Component {
draft.previews = draft.previews.concat(filenames);
PostStore.storeDraft(channelId, draft);
- this.setState({uploadsInProgress: draft.uploadsInProgress, previews: draft.previews});
+ if (channelId === this.state.channelId) {
+ this.setState({uploadsInProgress: draft.uploadsInProgress, previews: draft.previews});
+ }
}
- handleUploadError(err, clientId) {
+ handleUploadError(err, clientId, channelId) {
let message = err;
if (message && typeof message !== 'string') {
// err is an AppError from the server
@@ -263,16 +265,18 @@ class CreatePost extends React.Component {
}
if (clientId !== -1) {
- const draft = PostStore.getDraft(this.state.channelId);
+ const draft = PostStore.getDraft(channelId);
const index = draft.uploadsInProgress.indexOf(clientId);
if (index !== -1) {
draft.uploadsInProgress.splice(index, 1);
}
- PostStore.storeDraft(this.state.channelId, draft);
+ PostStore.storeDraft(channelId, draft);
- this.setState({uploadsInProgress: draft.uploadsInProgress});
+ if (channelId === this.state.channelId) {
+ this.setState({uploadsInProgress: draft.uploadsInProgress});
+ }
}
this.setState({serverError: message});
diff --git a/webapp/components/file_upload.jsx b/webapp/components/file_upload.jsx
index 8e4019f6f..8e631ac95 100644
--- a/webapp/components/file_upload.jsx
+++ b/webapp/components/file_upload.jsx
@@ -49,15 +49,15 @@ class FileUpload extends React.Component {
fileUploadSuccess(channelId, data) {
this.props.onFileUpload(data.filenames, data.client_ids, channelId);
- const requests = JSON.parse(JSON.stringify(this.state.requests));
+ const requests = Object.assign({}, this.state.requests);
for (var j = 0; j < data.client_ids.length; j++) {
Reflect.deleteProperty(requests, data.client_ids[j]);
}
this.setState({requests});
}
- fileUploadFail(clientId, err) {
- this.props.onUploadError(err, clientId);
+ fileUploadFail(clientId, channelId, err) {
+ this.props.onUploadError(err, clientId, channelId);
}
uploadFiles(files) {
@@ -86,7 +86,7 @@ class FileUpload extends React.Component {
channelId,
clientId,
this.fileUploadSuccess.bind(this, channelId),
- this.fileUploadFail.bind(this, clientId)
+ this.fileUploadFail.bind(this, clientId, channelId)
);
const requests = this.state.requests;