Skip to content

Commit 0bf0c2e

Browse files
ClearlyClairehiyuki2578
authored andcommitted
Fix upload progressbar when image resizing is involved (mastodon#10632)
1 parent 50fd960 commit 0bf0c2e

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

app/javascript/mastodon/actions/compose.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,8 @@ export function uploadCompose(files) {
203203
return function (dispatch, getState) {
204204
const uploadLimit = 4;
205205
const media = getState().getIn(['compose', 'media_attachments']);
206-
const total = Array.from(files).reduce((a, v) => a + v.size, 0);
207206
const progress = new Array(files.length).fill(0);
207+
let total = Array.from(files).reduce((a, v) => a + v.size, 0);
208208

209209
if (files.length + media.size > uploadLimit) {
210210
dispatch(showAlert(undefined, messages.uploadErrorLimit));
@@ -224,6 +224,8 @@ export function uploadCompose(files) {
224224
resizeImage(f).then(file => {
225225
const data = new FormData();
226226
data.append('file', file);
227+
// Account for disparity in size of original image and resized data
228+
total += file.size - f.size;
227229

228230
return api(getState).post('/api/v1/media', data, {
229231
onUploadProgress: function({ loaded }){

0 commit comments

Comments
 (0)