From de01a7e6797a0d5c73bccc709639ff4ba328b744 Mon Sep 17 00:00:00 2001
From: hmhealey <harrisonmhealey@gmail.com>
Date: Tue, 28 Jul 2015 18:37:21 -0400
Subject: Cleaned up ViewImageModal and FileAttachment and added some extra
 comments

---
 web/react/components/file_attachment.jsx | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

(limited to 'web/react/components/file_attachment.jsx')

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);
         }
 
-- 
cgit v1.2.3-1-g7c22

