]> cat aescling's git repositories - mastodon.git/commitdiff
Fix uninformative error message when uploading unsupported image files (#13540)
authorThibG <thib@sitedethib.com>
Sat, 25 Apr 2020 10:27:29 +0000 (12:27 +0200)
committerGitHub <noreply@github.com>
Sat, 25 Apr 2020 10:27:29 +0000 (12:27 +0200)
Attempting to upload image files that the browser is unable to load results
in “Oops! An unexpected error occurred.”

This commit changes the error handling so that an unprocessable image results
in the file being sent anyway, which might cover a few corner cases, and
provide a slightly better error message.

app/javascript/mastodon/utils/resize_image.js

index 710a08f7c7abfaf51814d7b66316b4360f833f11..6c1cb61a2535cd748907f93ebdfbe74a26f88c6c 100644 (file)
@@ -138,7 +138,7 @@ const resizeImage = (img, type = 'image/png') => new Promise((resolve, reject) =
     .catch(reject);
 });
 
-export default inputFile => new Promise((resolve, reject) => {
+export default inputFile => new Promise((resolve) => {
   if (!inputFile.type.match(/image.*/) || inputFile.type === 'image/gif') {
     resolve(inputFile);
     return;
@@ -153,5 +153,5 @@ export default inputFile => new Promise((resolve, reject) => {
     resizeImage(img, inputFile.type)
       .then(resolve)
       .catch(() => resolve(inputFile));
-  }).catch(reject);
+  }).catch(() => resolve(inputFile));
 });