From 9101e34ea4f3916adeb0c08fceb8eed2ffd97e04 Mon Sep 17 00:00:00 2001 From: Davit Barbakadze Date: Fri, 16 May 2014 12:21:41 +0400 Subject: [PATCH] Do not fire FilesAdded with the whole queue every time. Address #1073. --- src/plupload.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/plupload.js b/src/plupload.js index ede328b8f..7469c8335 100644 --- a/src/plupload.js +++ b/src/plupload.js @@ -1873,6 +1873,7 @@ plupload.Uploader = function(options) { addFile : function(file, fileName) { var self = this , queue = [] + , filesAdded = [] , ruid ; @@ -1924,7 +1925,11 @@ plupload.Uploader = function(options) { // run through the internal and user-defined filters, if any filterFile(file, function(err) { if (!err) { + // make files available for the filters by updating the main queue directly files.push(file); + // collect the files that will be passed to FilesAdded event + filesAdded.push(file); + self.trigger("FileFiltered", file); } delay(cb, 1); // do not build up recursions or eventually we might hit the limits @@ -1954,8 +1959,8 @@ plupload.Uploader = function(options) { if (queue.length) { o.inSeries(queue, function() { // if any files left after filtration, trigger FilesAdded - if (files.length) { - self.trigger("FilesAdded", files); + if (filesAdded.length) { + self.trigger("FilesAdded", filesAdded); } }); }