about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
authorThibG <thib@sitedethib.com>2019-04-25 02:48:54 +0200
committerEugen Rochko <eugen@zeonfederated.com>2019-04-25 02:48:54 +0200
commit852ccea676bbb8a91a0d1bc66570e68e6de2c9e1 (patch)
tree52ba0040ef0af09f7e00d6d57b43aebbb592a849 /app
parentb1a0322a06e6f8eca736132b1f7f2af8dc179afb (diff)
Fix upload progressbar when image resizing is involved (#10632)
Diffstat (limited to 'app')
-rw-r--r--app/javascript/mastodon/actions/compose.js4
1 files changed, 3 insertions, 1 deletions
diff --git a/app/javascript/mastodon/actions/compose.js b/app/javascript/mastodon/actions/compose.js
index d65d41048..0ee663766 100644
--- a/app/javascript/mastodon/actions/compose.js
+++ b/app/javascript/mastodon/actions/compose.js
@@ -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 }){