Fix uploaded files being previewed on wrong channels (#2860)

Этот коммит содержится в:
Joram Wilander
2016-05-03 11:00:06 -04:00
родитель 3a17fd86a0
Коммит 05a203b409
2 изменённых файлов: 13 добавлений и 9 удалений

Просмотреть файл

@@ -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});