From c277cbca8f36601536154e0775768f4ba76c454c Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Thu, 5 Sep 2024 10:50:18 +0200 Subject: [PATCH] Move unsupported files alert to outside the loop Co-authored-by: Lim Chee Aun --- src/components/compose.jsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/components/compose.jsx b/src/components/compose.jsx index d038e81f..3d034599 100644 --- a/src/components/compose.jsx +++ b/src/components/compose.jsx @@ -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, {