Bug 1571287 - Add isShowingJunkNotification for LookOut add-on. r=IanN a=IanN
authorFrank-Rainer Grahl <frgrahl@gmx.net>
Sun, 11 Aug 2019 14:11:04 +0200
changeset 32259 bee6a4cc555f5f324936c6029cbc6a46ceab14dc
parent 32258 2375c07411d59718c1323a98ab08eb603cec5d27
child 32260 b8df6618678c0e9d483e1eddef9ba8835f48da7f
push id209
push userfrgrahl@gmx.net
push dateSun, 11 Aug 2019 12:21:39 +0000
treeherdercomm-esr60@7a01e33fff91 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersIanN, IanN
bugs1571287
Bug 1571287 - Add isShowingJunkNotification for LookOut add-on. r=IanN a=IanN
suite/mailnews/content/mailWindowOverlay.js
--- a/suite/mailnews/content/mailWindowOverlay.js
+++ b/suite/mailnews/content/mailWindowOverlay.js
@@ -2492,31 +2492,33 @@ function HandleJunkStatusChanged(folder)
     return;
 
   // If multiple message are selected and we change the junk status
   // we don't want to show the junk bar (since the message pane is blank).
   var msgHdr = null;
   if (GetNumSelectedMessages() == 1)
     msgHdr = messenger.msgHdrFromURI(loadedMessage);
 
-  var junkBarWasDisplayed = gMessageNotificationBar.mMsgNotificationBar.getNotificationWithValue("junkContent");
+  var junkBarWasDisplayed = gMessageNotificationBar.isShowingJunkNotification();
   gMessageNotificationBar.setJunkMsg(msgHdr);
-  var isJunk = gMessageNotificationBar.mMsgNotificationBar.getNotificationWithValue("junkContent");
 
   // Only reload message if junk bar display state has changed.
-  if (msgHdr && junkBarWasDisplayed != isJunk)
+  if (msgHdr && junkBarWasDisplayed != gMessageNotificationBar.isShowingJunkNotification())
   {
     // We may be forcing junk mail to be rendered with sanitized html.
     // In that scenario, we want to reload the message if the status has just
     // changed to not junk.
     var sanitizeJunkMail = Services.prefs.getBoolPref("mail.spam.display.sanitize");
 
     // Only bother doing this if we are modifying the html for junk mail...
     if (sanitizeJunkMail)
     {
+      let junkScore = msgHdr.getStringProperty("junkscore");
+      let isJunk = (junkScore == Ci.nsIJunkMailPlugin.IS_SPAM_SCORE);
+
       // If the current row isn't going to change, reload to show sanitized or
       // unsanitized. Otherwise we wouldn't see the reloaded version anyway.
 
       // XXX: need to special handle last message in view, for imap mark as deleted
 
       // 1) When marking as non-junk, the msg would move back to the inbox.
       // 2) When marking as junk, the msg will move or delete, if manualMark is set.
       // 3) Marking as junk in the junk folder just changes the junk status.
@@ -2557,20 +2559,19 @@ var gMessageNotificationBar =
     if (aMsgHdr)
     {
       let junkScore = aMsgHdr.getStringProperty("junkscore");
       isJunk = ((junkScore != "") && (junkScore != "0"));
     }
 
     goUpdateCommand('button_junk');
 
-    let oldNotif = this.mMsgNotificationBar.getNotificationWithValue("junkContent");
     if (isJunk)
     {
-      if (!oldNotif)
+      if (!this.isShowingJunkNotification())
       {
         let brandName = this.mBrandBundle.getString("brandShortName");
         let junkBarMsg = this.mStringBundle.getFormattedString('junkBarMessage',
                                                             [brandName]);
 
         let buttons = [{
           label: this.mStringBundle.getString('junkBarInfoButton'),
           accessKey: this.mStringBundle.getString('junkBarInfoButtonKey'),
@@ -2595,16 +2596,20 @@ var gMessageNotificationBar =
           null, this.mMsgNotificationBar.PRIORITY_WARNING_HIGH, buttons);
         this.mMsgNotificationBar.collapsed = false;
       }
     }
   },
 
   remoteOrigins: null,
 
+  isShowingJunkNotification: function() {
+    return !!this.mMsgNotificationBar.getNotificationWithValue("junkContent");
+  },
+
   setRemoteContentMsg: function(aMsgHdr, aContentURI, aCanOverride)
   {
     // remoteOrigins is a Set of all blockable Origins.
     if (!this.remoteOrigins)
       this.remoteOrigins = new Set();
 
     var origin = aContentURI.spec;
     try