From 23f6cdf3aa0e4c3f17151c615084b0360b0674a3 Mon Sep 17 00:00:00 2001 From: David Lu Date: Mon, 9 May 2016 11:58:00 -0400 Subject: PLT-2814 Fixed JavaScript errors upon paste (#2932) * Fixed JavaScript errors on paste * Reverted keycode * Removed all mentions of self * Find and replace got a comment * Fixed file upload on drag and drop --- webapp/components/file_upload.jsx | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'webapp/components') diff --git a/webapp/components/file_upload.jsx b/webapp/components/file_upload.jsx index 5734dc01e..05f1701a8 100644 --- a/webapp/components/file_upload.jsx +++ b/webapp/components/file_upload.jsx @@ -132,7 +132,6 @@ class FileUpload extends React.Component { componentDidMount() { var self = this; - if (this.props.postType === 'post') { $('.row.main').dragster({ enter(dragsterEvent, e) { @@ -210,7 +209,7 @@ class FileUpload extends React.Component { return; } - self.props.onUploadError(null); + this.props.onUploadError(null); // This looks redundant, but must be done this way due to // setState being an asynchronous call @@ -229,10 +228,10 @@ class FileUpload extends React.Component { } } - var numToUpload = Math.min(Constants.MAX_UPLOAD_FILES - self.props.getFileCount(ChannelStore.getCurrentId()), numItems); + var numToUpload = Math.min(Constants.MAX_UPLOAD_FILES - this.props.getFileCount(ChannelStore.getCurrentId()), numItems); if (numItems > numToUpload) { - self.props.onUploadError(formatMessage(holders.limited, {count: Constants.MAX_UPLOAD_FILES})); + this.props.onUploadError(formatMessage(holders.limited, {count: Constants.MAX_UPLOAD_FILES})); } for (var i = 0; i < items.length && i < numToUpload; i++) { @@ -244,7 +243,7 @@ class FileUpload extends React.Component { if (Constants.IMAGE_TYPES.indexOf(ext) < 0) { continue; } - var channelId = self.props.channelId || ChannelStore.getCurrentId(); + var channelId = this.props.channelId || ChannelStore.getCurrentId(); // generate a unique id that can be used by other components to refer back to this file upload var clientId = Utils.generateId(); @@ -269,15 +268,15 @@ class FileUpload extends React.Component { name, channelId, clientId, - self.fileUploadSuccess.bind(self, channelId), - self.fileUploadFail.bind(self, clientId) + this.fileUploadSuccess.bind(this, channelId), + this.fileUploadFail.bind(this, clientId) ); - const requests = self.state.requests; + const requests = this.state.requests; requests[clientId] = request; - self.setState({requests}); + this.setState({requests}); - self.props.onUploadStart([clientId], channelId); + this.props.onUploadStart([clientId], channelId); } } } -- cgit v1.2.3-1-g7c22