From 009df5bad5f55c7e4c698f9dab8420d00a7ae71e Mon Sep 17 00:00:00 2001
From: JoramWilander <jwawilander@gmail.com>
Date: Mon, 22 Jun 2015 08:35:24 -0400
Subject: fixes mm-1318 only allow 5 files to be uploaded at a time

---
 web/react/components/file_upload.jsx | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

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

diff --git a/web/react/components/file_upload.jsx b/web/react/components/file_upload.jsx
index c03a61c63..f2429f17e 100644
--- a/web/react/components/file_upload.jsx
+++ b/web/react/components/file_upload.jsx
@@ -12,18 +12,18 @@ module.exports = React.createClass({
 
         this.props.onUploadError(null);
 
-        //This looks redundant, but must be done this way due to
-        //setState being an asynchronous call
+        // This looks redundant, but must be done this way due to
+        // setState being an asynchronous call
         var numFiles = 0;
-        for(var i = 0; i < files.length && i <= 20 ; i++) {
+        for(var i = 0; i < files.length && i < Constants.MAX_UPLOAD_FILES; i++) {
             if (files[i].size <= Constants.MAX_FILE_SIZE) {
                 numFiles++;
             }
         }
 
-        this.props.setUploads(numFiles);
+        var numToUpload = this.props.setUploads(numFiles);
 
-        for (var i = 0; i < files.length && i <= 20; i++) {
+        for (var i = 0; i < files.length && i < numToUpload; i++) {
             if (files[i].size > Constants.MAX_FILE_SIZE) {
                 this.props.onUploadError("Files must be no more than " + Constants.MAX_FILE_SIZE/1000000 + " MB");
                 continue;
@@ -70,8 +70,8 @@ module.exports = React.createClass({
 
             self.props.onUploadError(null);
 
-            //This looks redundant, but must be done this way due to
-            //setState being an asynchronous call
+            // This looks redundant, but must be done this way due to
+            // setState being an asynchronous call
             var items = e.clipboardData.items;
             var numItems = 0;
             if (items) {
@@ -87,9 +87,9 @@ module.exports = React.createClass({
                     }
                 }
 
-                self.props.setUploads(numItems);
+                var numToUpload = self.props.setUploads(numItems);
 
-                for (var i = 0; i < items.length; i++) {
+                for (var i = 0; i < items.length && i < numToUpload; i++) {
                     if (items[i].type.indexOf("image") !== -1) {
                         var file = items[i].getAsFile();
 
-- 
cgit v1.2.3-1-g7c22

