Bug 1556981 - Reshuffle icon logic for attachments since *-message URLs are mailnews URLs now. r=aceman
authorJorg K <jorgk@jorgk.com>
Thu, 06 Jun 2019 01:21:00 +0200
changeset 35795 2600d6fff1bf31331265cb78a3ce576b8ab9257e
parent 35794 b492a5b976afeb2461bd0a8bffb9ab835d679dab
child 35796 31427e4cdbef2f74adb62f68fe28e3c25fe8ff20
push id392
push userclokep@gmail.com
push dateMon, 02 Sep 2019 20:17:19 +0000
reviewersaceman
bugs1556981
Bug 1556981 - Reshuffle icon logic for attachments since *-message URLs are mailnews URLs now. r=aceman
mail/components/compose/content/MsgComposeCommands.js
--- a/mail/components/compose/content/MsgComposeCommands.js
+++ b/mail/components/compose/content/MsgComposeCommands.js
@@ -4384,32 +4384,33 @@ function AddAttachments(aAttachments, aC
       try {
         let account = cloudFileAccounts.getAccount(attachment.cloudFileAccountKey);
         item.cloudFileAccount = account;
         item.image = account.iconURL;
         item.originalUrl = attachment.url;
       } catch (ex) {
         dump(ex);
       }
+
+    // For local file urls, we are better off using the full file url because
+    // moz-icon will actually resolve the file url and get the right icon from
+    // the file url. All other urls, we should try to extract the file name from
+    // them. This fixes issues where an icon wasn't showing up if you dragged a
+    // web url that had a query or reference string after the file name and for
+    // mailnews urls where the filename is hidden in the url as a &filename=
+    // part.
+    } else if (/^mailbox-message:|^imap-message:|^news-message:/i.test(attachment.url)) {
+      // We're attaching a message. Pretend that is comes from a file,
+      // so we get the icon that matches .eml files.
+      item.image = "moz-icon://message.eml";
     } else {
-      // For local file urls, we are better off using the full file url because
-      // moz-icon will actually resolve the file url and get the right icon from
-      // the file url. All other urls, we should try to extract the file name from
-      // them. This fixes issues where an icon wasn't showing up if you dragged a
-      // web url that had a query or reference string after the file name and for
-      // mailnews urls where the filename is hidden in the url as a &filename=
-      // part.
       let url = Services.io.newURI(attachment.url);
       if (url instanceof Ci.nsIURL &&
           url.fileName && !url.schemeIs("file")) {
         item.image = "moz-icon://" + url.fileName;
-      } else if (/^mailbox-message:|^imap-message:|^news-message:/i.test(attachment.url)) {
-        // We're attaching a message, most likely via drag and drop. Pretend that is comes
-        // from a file, so we get the icon that matches .eml files.
-        item.image = "moz-icon://message.eml";
       } else {
         item.image = "moz-icon:" + attachment.url;
       }
     }
 
     items.push(item);
 
     if (aCallback)