Move unsupported files alert to outside the loop

Co-authored-by: Lim Chee Aun <cheeaun@gmail.com>
This commit is contained in:
Stefano Pigozzi 2024-09-05 10:50:18 +02:00
parent 53f7c39c77
commit c277cbca8f
No known key found for this signature in database
GPG key ID: 5ADA3868646C3FC0

View file

@ -600,6 +600,7 @@ function Compose({
const handleItems = (e) => {
const { items } = e.clipboardData || e.dataTransfer;
const files = [];
const unsupportedFiles = [];
for (let i = 0; i < items.length; i++) {
const item = items[i];
if (item.kind === 'file') {
@ -609,14 +610,21 @@ function Compose({
return;
}
else if (supportedMimeTypes !== undefined && !supportedMimeTypes.includes(file.type)) {
alert(t`File "${file.name}" is not supported by your instance.`);
return;
unsupportedFiles.push(file);
}
else {
files.push(file);
}
}
}
if (unsupportedFiles.length > 0) {
alert(
plural(unsupportedFiles.length, {
one: `File ${unsupportedFiles[0]} is not supported by your instance.`,
other: `Files ${unsupportedFiles.join(", ")} are not supported by your instance.`,
}),
);
}
if (files.length > 0 && mediaAttachments.length >= maxMediaAttachments) {
alert(
plural(maxMediaAttachments, {