Bug 1427265 - provide better moz-icon for messages attached via drag&drop. r=aceman
authorJorg K <jorgk@jorgk.com>
Sat, 30 Dec 2017 00:20:43 +0100
changeset 22941 a64eb1d3d9166d389f95c4ab8aad6384bcc10ff1
parent 22940 4469c475c6b473927956f509a1ef78da8db5e48c
child 22942 678a35e90cfeb5dd5589d7ade973a05eb8f71e33
push id13890
push usermozilla@jorgk.com
push dateSat, 30 Dec 2017 10:48:18 +0000
treeherdercomm-central@678a35e90cfe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaceman
bugs1427265
Bug 1427265 - provide better moz-icon for messages attached via drag&drop. r=aceman
mail/components/compose/content/MsgComposeCommands.js
--- a/mail/components/compose/content/MsgComposeCommands.js
+++ b/mail/components/compose/content/MsgComposeCommands.js
@@ -4484,21 +4484,26 @@ function AddAttachments(aAttachments, aC
       // 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 Components.interfaces.nsIURL &&
-          url.fileName && !url.schemeIs("file"))
+          url.fileName && !url.schemeIs("file")) {
         item.image = "moz-icon://" + url.fileName;
-      else
+      } 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)
       aCallback(item);
   }
 
   if (addedAttachments.length > 0) {