Compare commits

...

3 Commits

Author SHA1 Message Date
Rens Groothuijsen
5454046b5e
Merge 809846b23a into 94bceb8683 2025-07-11 14:03:35 +00:00
Rens Groothuijsen
809846b23a Remove redundant upload limit variable and check number of attached files only once 2025-06-25 09:56:29 +02:00
Rens Groothuijsen
9380ace992 Rebase branch 2025-06-25 09:56:29 +02:00

View File

@ -298,14 +298,20 @@ export function submitComposeFail(error) {
export function uploadCompose(files) {
return function (dispatch, getState) {
const uploadLimit = getState().getIn(['server', 'server', 'configuration', 'statuses', 'max_media_attachments']);
const media = getState().getIn(['compose', 'media_attachments']);
const pending = getState().getIn(['compose', 'pending_media_attachments']);
const serverConfiguration = getState().getIn(['server', 'server', 'configuration']);
const maxMediaAttachments = serverConfiguration.getIn(['statuses', 'max_media_attachments']);
const videoSizeLimit = serverConfiguration.getIn(['media_attachments', 'video_size_limit']);
const imageSizeLimit = serverConfiguration.getIn(['media_attachments', 'image_size_limit']);
const filesArray = Array.from(files);
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 + pending > uploadLimit) {
let total = filesArray.reduce((a, v) => a + v.size, 0);
if (files.length + media.size + pending > maxMediaAttachments
|| filesArray.some(file => (
file.type.match(/video\/.*/) && file.size > videoSizeLimit)
|| (file.type.match(/image\/.*/) && file.size > imageSizeLimit)))
{
dispatch(showAlert({ message: messages.uploadErrorLimit }));
return;
}
@ -318,7 +324,7 @@ export function uploadCompose(files) {
dispatch(uploadComposeRequest());
for (const [i, file] of Array.from(files).entries()) {
if (media.size + i > (uploadLimit - 1)) break;
if (media.size + i > (maxMediaAttachments - 1)) break;
const data = new FormData();
data.append('file', file);