]> cat aescling's git repositories - mastodon.git/commitdiff
Fix upload progressbar when image resizing is involved
authorThibaut Girka <thib@sitedethib.com>
Wed, 24 Apr 2019 15:59:11 +0000 (17:59 +0200)
committerThibG <thib@sitedethib.com>
Wed, 24 Apr 2019 18:19:23 +0000 (20:19 +0200)
app/javascript/flavours/glitch/actions/compose.js

index ac09adcebd070a5b1151b43a6b3360d923c3e196..ef2500629f7c5ec02004c23400713e0dac07973e 100644 (file)
@@ -227,8 +227,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));
@@ -248,6 +248,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 }){