]> cat aescling's git repositories - mastodon.git/commitdiff
Fix upload progressbar when image resizing is involved (#10632)
authorThibG <thib@sitedethib.com>
Thu, 25 Apr 2019 00:48:54 +0000 (02:48 +0200)
committerEugen Rochko <eugen@zeonfederated.com>
Thu, 25 Apr 2019 00:48:54 +0000 (02:48 +0200)
app/javascript/mastodon/actions/compose.js

index d65d4104826beaceb5e21c88fe9d9da77aa1e70f..0ee663766ab3684ce93c1e2015a63f7e24ad2bdf 100644 (file)
@@ -203,8 +203,8 @@ export function uploadCompose(files) {
   return function (dispatch, getState) {
     const uploadLimit = 4;
     const media  = getState().getIn(['compose', 'media_attachments']);
-    const total = Array.from(files).reduce((a, v) => a + v.size, 0);
     const progress = new Array(files.length).fill(0);
+    let total = Array.from(files).reduce((a, v) => a + v.size, 0);
 
     if (files.length + media.size > uploadLimit) {
       dispatch(showAlert(undefined, messages.uploadErrorLimit));
@@ -224,6 +224,8 @@ export function uploadCompose(files) {
       resizeImage(f).then(file => {
         const data = new FormData();
         data.append('file', file);
+        // Account for disparity in size of original image and resized data
+        total += file.size - f.size;
 
         return api(getState).post('/api/v1/media', data, {
           onUploadProgress: function({ loaded }){