Browse Source

Fix sending multiple files via attachment button (#337)

Fixes #330
Silly 8 years ago
parent
commit
9466e3aa85
1 changed files with 4 additions and 4 deletions
  1. 4 4
      src/directives/compose_area.ts

+ 4 - 4
src/directives/compose_area.ts

@@ -247,14 +247,14 @@ export default [
                 function fetchFileListContents(fileList: FileList): Promise<Map<File, ArrayBuffer>> {
                     return new Promise((resolve) => {
                         let buffers = new Map<File, ArrayBuffer>();
+                        const fileCounter = fileList.length;
                         let next = (file: File, res: ArrayBuffer | null, error: any) => {
                             buffers.set(file, res);
-                            if (buffers.size >= fileList.length) {
+                            if (buffers.size >= fileCounter) {
                                resolve(buffers);
                             }
                         };
-
-                        for (let n = 0; n < fileList.length; n++) {
+                        for (let n = 0; n < fileCounter; n++) {
                             const reader = new FileReader();
                             const file = fileList.item(n);
                             reader.onload = (ev: Event) => {
@@ -267,7 +267,7 @@ export default [
                             reader.onprogress = function(data) {
                                 if (data.lengthComputable) {
                                     let progress = ((data.loaded / data.total) * 100);
-                                    scope.onUploading(true, progress, 100 / fileList.length * n);
+                                    scope.onUploading(true, progress, 100 / fileCounter * n);
                                 }
                             };
                             reader.readAsArrayBuffer(file);