Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Pleroma
mastofe
Commits
e365d3f3
Verified
Commit
e365d3f3
authored
Jul 04, 2018
by
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
9d23fd78
Changes
1
Hide whitespace changes
Inline
Side-by-side
app/javascript/flavours/glitch/actions/compose.js
View file @
e365d3f3
...
...
@@ -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,22 +243,23 @@ export function uploadCompose(files) {
dispatch
(
uploadComposeRequest
());
for
(
const
[
i
,
f
]
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/v1/media
'
,
data
,
{
onUploadProgress
:
function
({
loaded
}){
progress
[
i
]
=
loaded
;
dispatch
(
uploadComposeProgress
(
progress
.
reduce
((
a
,
v
)
=>
a
+
v
,
0
),
total
));
},
}).
then
(({
data
})
=>
dispatch
(
uploadComposeSuccess
(
data
,
f
)));
}).
catch
(
error
=>
dispatch
(
uploadComposeFail
(
error
)));
for
(
const
[
i
,
file
]
of
Array
.
from
(
files
).
entries
())
{
// Looks useless or should reuse uploadLimit
// if (media.size + i > 3) break;
const
data
=
new
FormData
();
data
.
append
(
'
file
'
,
file
);
api
(
getState
).
post
(
'
/api/v1/media
'
,
data
,
{
onUploadProgress
:
function
({
loaded
}){
progress
[
i
]
=
loaded
;
dispatch
(
uploadComposeProgress
(
progress
.
reduce
((
a
,
v
)
=>
a
+
v
,
0
),
total
));
},
}).
then
(
function
(
response
)
{
dispatch
(
uploadComposeSuccess
(
response
.
data
,
file
));
}).
catch
(
function
(
error
)
{
dispatch
(
uploadComposeFail
(
error
));
});
};
};
};
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment