flowjs / ng-flow

Flow.js html5 file upload extension on angular.js framework
http://flowjs.github.io/ng-flow/
MIT License
1.38k stars 303 forks source link

Callback for flow-files-submitted returns different number of files in the same folder #344

Closed psmyrdek closed 6 years ago

psmyrdek commented 6 years ago

Hi! I'm using ng-flow on two different pages in my app. One is classic / legacy one, based on jQuery 1 and Angular 1.5, and another one has jQuery 3 and hybrid Angular / Angular.js implementation. When I'm trying to upload the same folder using flow-files-submitted directive, it's handler is being executed with differend number of files for each page.

In my view it looks like this: flow-files-submitted="$ctrl.filesManager.onFilesSubmitted($files, $event, $flow)"

And this handler is doing pretty straightforward job - it has to check number of files uploaded and redirect operation to a proper method. I'm using switch clause for this:

fm.onFilesSubmitted = function ($files, $event, $flow) {
            switch ($flow.files.length) {
                case 0:
                    $flow.cancel();
                    break;
                case 1:
                    callbacks.onSingleSelected({});
                    break;
                default:
                    callbacks.onMultipleSelected({});
            }
        };

The problem is that $flow.files.length, for folder with 4 files, is equal to 1 on one page, and to 4 on another. At the same time, $files.length seems to be fine - all the time it's value is equal to 4. Page where the value is equal to one is this hybrid app with newer Angular. Do you know if this may cause any problems with ng-flow?

Are there any drawbacks in using $files instead of checking $flow object then?

Deps I'm using:

"ng-flow": "2.7.7"
"@flowjs/flow.js": "git://github.com/flowjs/flow.js.git",