Verified Commit f6ec8afc authored by Haelwenn's avatar Haelwenn
Browse files

Revert: Resize images before upload in web UI to reduce bandwidth

Closes: #22

(Can also fix an issue with canvas and the Tor Browser)
parent 2fa8015c
......@@ -5,7 +5,6 @@ import { search as emojiSearch } from 'flavours/glitch/util/emoji/emoji_mart_sea
import { useEmoji } from './emojis';
import { tagHistory } from 'flavours/glitch/util/settings';
import { recoverHashtags } from 'flavours/glitch/util/hashtag';
import resizeImage from 'flavours/glitch/util/resize_image';
import { importFetchedAccounts } from './importer';
import { updateTimeline } from './timelines';
import { showAlertForError } from './alerts';
......@@ -244,14 +243,11 @@ export function uploadCompose(files) {
dispatch(uploadComposeRequest());
for (const [i, f] of Array.from(files).entries()) {
for (const [i, file] of Array.from(files).entries()) {
if (media.size + i > 3) break;
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/v2/media', data, {
onUploadProgress: function({ loaded }){
......@@ -263,12 +259,12 @@ export function uploadCompose(files) {
// poll the server until it is, before showing the media attachment as uploaded
if (status === 200) {
dispatch(uploadComposeSuccess(data, f));
dispatch(uploadComposeSuccess(data, file));
} else if (status === 202) {
const poll = () => {
api(getState).get(`/api/v1/media/${data.id}`).then(response => {
if (response.status === 200) {
dispatch(uploadComposeSuccess(response.data, f));
dispatch(uploadComposeSuccess(response.data, file));
} else if (response.status === 206) {
setTimeout(() => poll(), 1000);
}
......@@ -278,7 +274,6 @@ export function uploadCompose(files) {
poll();
}
});
}).catch(error => dispatch(uploadComposeFail(error)));
};
};
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment