mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
Fix uploaded files being previewed on wrong channels (#2860)
This commit is contained in:
@@ -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});
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user