diff options
author | hmhealey <harrisonmhealey@gmail.com> | 2015-07-28 18:37:21 -0400 |
---|---|---|
committer | hmhealey <harrisonmhealey@gmail.com> | 2015-07-29 10:18:58 -0400 |
commit | de01a7e6797a0d5c73bccc709639ff4ba328b744 (patch) | |
tree | e61c1044456152f63e43e3183ec84776ab7fe31f /web/react/components/file_attachment.jsx | |
parent | 782e7b03adc6cf322dd7d9a95490d264399a5a90 (diff) | |
download | chat-de01a7e6797a0d5c73bccc709639ff4ba328b744.tar.gz chat-de01a7e6797a0d5c73bccc709639ff4ba328b744.tar.bz2 chat-de01a7e6797a0d5c73bccc709639ff4ba328b744.zip |
Cleaned up ViewImageModal and FileAttachment and added some extra comments
Diffstat (limited to 'web/react/components/file_attachment.jsx')
-rw-r--r-- | web/react/components/file_attachment.jsx | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/web/react/components/file_attachment.jsx b/web/react/components/file_attachment.jsx index 57a064ff4..3cd791887 100644 --- a/web/react/components/file_attachment.jsx +++ b/web/react/components/file_attachment.jsx @@ -7,9 +7,13 @@ module.exports = React.createClass({ displayName: "FileAttachment", canSetState: false, propTypes: { + // a list of file pathes displayed by the parent FileAttachmentList filenames: React.PropTypes.arrayOf(React.PropTypes.string).isRequired, + // the index of this attachment preview in the parent FileAttachmentList index: React.PropTypes.number.isRequired, + // the identifier of the modal dialog used to preview files modalId: React.PropTypes.string.isRequired, + // handler for when the thumbnail is clicked handleImageClick: React.PropTypes.func }, getInitialState: function() { @@ -20,12 +24,8 @@ module.exports = React.createClass({ var filename = this.props.filenames[this.props.index]; - var self = this; - if (filename) { var fileInfo = utils.splitFileLocation(filename); - if (Object.keys(fileInfo).length === 0) return; - var type = utils.getFileType(fileInfo.ext); // This is a temporary patch to fix issue with old files using absolute paths @@ -35,6 +35,7 @@ module.exports = React.createClass({ fileInfo.path = utils.getWindowLocationOrigin() + "/api/v1/files/get" + fileInfo.path; if (type === "image") { + var self = this; $('<img/>').attr('src', fileInfo.path+'_thumb.jpg').load(function(path, name){ return function() { $(this).remove(); if (name in self.refs) { @@ -87,6 +88,7 @@ module.exports = React.createClass({ thumbnail = <div className={"file-icon "+utils.getIconClassName(type)}/>; } + var fileSizeString = ""; if (this.state.fileSize < 0) { var self = this; @@ -96,10 +98,7 @@ module.exports = React.createClass({ self.setState({fileSize: fileSize}); } }); - } - - var fileSizeString = ""; - if (this.state.fileSize >= 0) { + } else { fileSizeString = utils.fileSizeToString(this.state.fileSize); } |