Browse Source

Fix multiple issues on async uploads (not resumable) (#1568)

- general progress bar would not stay on cancelled status because of a set timeout on fnComplete
   removing setTimeout on fnComplete because it is not usefull to do so

 - rm is undefined on async upload (not resumable)
   check rm before assigning pool, this is because self.resumableManager is undefined in that case
   so it would throw an unhandled error
Jérémy Munsch 5 years ago
parent
commit
c22ffa981c
1 changed files with 13 additions and 15 deletions
  1. 13 15
      js/fileinput.js

+ 13 - 15
js/fileinput.js

@@ -3454,20 +3454,18 @@
                 }, self.processDelay);
             };
             fnComplete = function () {
-                setTimeout(function () {
-                    if (self.showPreview) {
-                        $btnUpload.removeAttr('disabled');
-                        $btnDelete.removeAttr('disabled');
-                        $thumb.removeClass('file-uploading');
-                    }
-                    if (!isBatch) {
-                        self.unlock(false);
-                        self._clearFileInput();
-                    } else {
-                        chkComplete();
-                    }
-                    self._initSuccessThumbs();
-                }, self.processDelay);
+                if (self.showPreview) {
+                    $btnUpload.removeAttr('disabled');
+                    $btnDelete.removeAttr('disabled');
+                    $thumb.removeClass('file-uploading');
+                }
+                if (!isBatch) {
+                    self.unlock(false);
+                    self._clearFileInput();
+                } else {
+                    chkComplete();
+                }
+                self._initSuccessThumbs();
             };
             fnError = function (jqXHR, textStatus, errorThrown) {
                 errMsg = self._parseError(op, jqXHR, errorThrown, self.fileManager.getFileName(id));
@@ -5378,7 +5376,7 @@
         cancel: function () {
             var self = this, xhr = self.ajaxRequests,
                 rm = self.resumableManager, tm = self.taskManager,
-                pool = tm.getPool(rm.id), len = xhr.length, i;
+                pool = rm ? tm.getPool(rm.id) : undefined, len = xhr.length, i;
 
             if (self.enableResumableUpload && pool) {
                 pool.cancel().done(function () {