diff options
author | Joram Wilander <jwawilander@gmail.com> | 2015-09-02 18:33:42 -0400 |
---|---|---|
committer | Joram Wilander <jwawilander@gmail.com> | 2015-09-02 18:33:42 -0400 |
commit | 25dac9a503b734379733cc1b0cb5179580d64fda (patch) | |
tree | 40748986781b0075a782ebf1b31c238069ba3354 /web/react | |
parent | 723e0756e89597128ff01c53cf03482d31b1ddfd (diff) | |
parent | ccd5fa39ac57c078853e10c68f074d718c640045 (diff) | |
download | chat-25dac9a503b734379733cc1b0cb5179580d64fda.tar.gz chat-25dac9a503b734379733cc1b0cb5179580d64fda.tar.bz2 chat-25dac9a503b734379733cc1b0cb5179580d64fda.zip |
Merge pull request #567 from mattermost/fix-style
Fixing style
Diffstat (limited to 'web/react')
-rw-r--r-- | web/react/components/file_upload.jsx | 60 |
1 files changed, 21 insertions, 39 deletions
diff --git a/web/react/components/file_upload.jsx b/web/react/components/file_upload.jsx index c91d03599..dcb938cbf 100644 --- a/web/react/components/file_upload.jsx +++ b/web/react/components/file_upload.jsx @@ -18,6 +18,21 @@ export default class FileUpload extends React.Component { }; } + fileUploadSuccess(channelId, data) { + var parsedData = $.parseJSON(data); + this.props.onFileUpload(parsedData.filenames, parsedData.client_ids, channelId); + + var requests = this.state.requests; + for (var j = 0; j < parsedData.client_ids.length; j++) { + delete requests[parsedData.client_ids[j]]; + } + this.setState({requests: requests}); + } + + fileUploadFail(clientId, err) { + this.props.onUploadError(err, clientId); + } + handleChange() { var element = $(React.findDOMNode(this.refs.fileInput)); var files = element.prop('files'); @@ -57,19 +72,8 @@ export default class FileUpload extends React.Component { formData.append('client_ids', clientId); var request = client.uploadFile(formData, - function success(data) { - var parsedData = $.parseJSON(data); - this.props.onFileUpload(parsedData.filenames, parsedData.client_ids, channelId); - - var requests = this.state.requests; - for (var j = 0; j < parsedData.client_ids.length; j++) { - delete requests[parsedData.client_ids[j]]; - } - this.setState({requests: requests}); - }.bind(this), - function fail(err) { - this.props.onUploadError(err, clientId); - }.bind(this) + this.fileUploadSuccess.bind(this, channelId), + this.fileUploadFail.bind(this, clientId) ); var requests = this.state.requests; @@ -122,19 +126,8 @@ export default class FileUpload extends React.Component { formData.append('client_ids', clientId); var request = client.uploadFile(formData, - function success(data) { - var parsedData = $.parseJSON(data); - this.props.onFileUpload(parsedData.filenames, parsedData.client_ids, channelId); - - var requests = this.state.requests; - for (var j = 0; j < parsedData.client_ids.length; j++) { - delete requests[parsedData.client_ids[j]]; - } - this.setState({requests: requests}); - }.bind(this), - function fail(err) { - this.props.onUploadError(err, clientId); - }.bind(this) + this.fileUploadSuccess.bind(this, channelId), + this.fileUploadFail.bind(this, clientId) ); var requests = this.state.requests; @@ -248,19 +241,8 @@ export default class FileUpload extends React.Component { formData.append('client_ids', clientId); var request = client.uploadFile(formData, - function(data) { - var parsedData = $.parseJSON(data); - self.props.onFileUpload(parsedData.filenames, parsedData.client_ids, channelId); - - var requests = self.state.requests; - for (var j = 0; j < parsedData.client_ids.length; j++) { - delete requests[parsedData.client_ids[j]]; - } - self.setState({requests: requests}); - }, - function(err) { - self.props.onUploadError(err, clientId); - } + self.fileUploadSuccess.bind(self, channelId), + self.fileUploadFail.bind(self, clientId) ); var requests = self.state.requests; |