Skip to content

Commit

Permalink
Do not fire FilesAdded with the whole queue every time. Address #1073.
Browse files Browse the repository at this point in the history
  • Loading branch information
jayarjo committed May 16, 2014
1 parent 3912c24 commit 9101e34
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/plupload.js
Original file line number Diff line number Diff line change
Expand Up @@ -1873,6 +1873,7 @@ plupload.Uploader = function(options) {
addFile : function(file, fileName) {
var self = this
, queue = []
, filesAdded = []
, ruid
;

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
});
}
Expand Down

0 comments on commit 9101e34

Please sign in to comment.