From 6f68c508ee3fd8c54fc1ba314cc60bae3f0b2600 Mon Sep 17 00:00:00 2001
From: Reed Garmsen <rgarmsen2295@gmail.com>
Date: Thu, 13 Aug 2015 15:44:38 -0700
Subject: Better error checking along with other fixes

---
 web/react/components/create_post.jsx | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

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

diff --git a/web/react/components/create_post.jsx b/web/react/components/create_post.jsx
index 137420440..377e7bd34 100644
--- a/web/react/components/create_post.jsx
+++ b/web/react/components/create_post.jsx
@@ -145,16 +145,20 @@ module.exports = React.createClass({
         this.setState({uploadsInProgress: draft['uploadsInProgress'], previews: draft['previews']});
     },
     handleUploadError: function(err, clientId) {
-        var draft = PostStore.getDraft(this.state.channelId);
+        if (clientId !== -1) {
+            var draft = PostStore.getDraft(this.state.channelId);
 
-        var index = draft['uploadsInProgress'].indexOf(clientId);
-        if (index !== -1) {
-            draft['uploadsInProgress'].splice(index, 1);
-        }
+            var index = draft['uploadsInProgress'].indexOf(clientId);
+            if (index !== -1) {
+                draft['uploadsInProgress'].splice(index, 1);
+            }
 
-        PostStore.storeDraft(this.state.channelId, draft);
+            PostStore.storeDraft(this.state.channelId, draft);
 
-        this.setState({uploadsInProgress: draft['uploadsInProgress'], serverError: err});
+            this.setState({uploadsInProgress: draft['uploadsInProgress'], serverError: err});
+        } else {
+            this.setState({serverError: err});
+        }
     },
     removePreview: function(id) {
         var previews = this.state.previews;
-- 
cgit v1.2.3-1-g7c22

