diff options
Diffstat (limited to 'web/react/components/create_post.jsx')
-rw-r--r-- | web/react/components/create_post.jsx | 30 |
1 files changed, 10 insertions, 20 deletions
diff --git a/web/react/components/create_post.jsx b/web/react/components/create_post.jsx index b32b53749..a4107d4fc 100644 --- a/web/react/components/create_post.jsx +++ b/web/react/components/create_post.jsx @@ -128,7 +128,7 @@ module.exports = React.createClass({ $(".post-list-holder-by-time").css("height", height + "px"); $(window).trigger('resize'); }, - handleUploadStart: function(filenames, channel_id) { + handleUploadStart: function(clientIds, channel_id) { var draft = PostStore.getDraft(channel_id); if (!draft) { draft = {}; @@ -137,12 +137,12 @@ module.exports = React.createClass({ draft['previews'] = []; } - draft['uploadsInProgress'] = draft['uploadsInProgress'].concat(filenames); + draft['uploadsInProgress'] = draft['uploadsInProgress'].concat(clientIds); PostStore.storeDraft(channel_id, draft); this.setState({uploadsInProgress: draft['uploadsInProgress']}); }, - handleFileUploadComplete: function(filenames, channel_id) { + handleFileUploadComplete: function(filenames, clientIds, channel_id) { var draft = PostStore.getDraft(channel_id); if (!draft) { draft = {}; @@ -152,18 +152,8 @@ module.exports = React.createClass({ } // remove each finished file from uploads - for (var i = 0; i < filenames.length; i++) { - var filename = filenames[i]; - - // filenames returned by the server include a path while stored uploads only have the actual file name - var index = -1; - for (var j = 0; j < draft['uploadsInProgress'].length; j++) { - var upload = draft['uploadsInProgress'][j]; - if (upload.indexOf(filename, upload.length - filename.length)) { - index = j; - break; - } - } + for (var i = 0; i < clientIds.length; i++) { + var index = draft['uploadsInProgress'].indexOf(clientIds[i]); if (index != -1) { draft['uploadsInProgress'].splice(index, 1); @@ -178,20 +168,20 @@ module.exports = React.createClass({ handleUploadError: function(err) { this.setState({ server_error: err }); }, - removePreview: function(filename) { + removePreview: function(id) { var previews = this.state.previews; var uploadsInProgress = this.state.uploadsInProgress; - // this can be either an uploaded file or an in progress upload that we need to remove - var index = previews.indexOf(filename); + // id can either be the path of an uploaded file or the client id of an in progress upload + var index = previews.indexOf(id); if (index !== -1) { previews.splice(index, 1); } else { - index = uploadsInProgress.indexOf(filename); + index = uploadsInProgress.indexOf(id); if (index !== -1) { uploadsInProgress.splice(index, 1); - this.refs.fileUpload.cancelUpload(filename); + this.refs.fileUpload.cancelUpload(id); } } |