Bug 1631184 - Marking messages as read or flagged with browser.messages.update fails to persist for IMAP folders. r=darktrojan a=wsmwk
authorMark Banner <standard8@mozilla.com>
Mon, 20 Apr 2020 13:49:00 +0300
changeset 38714 e38f495e52974c34b63b57c39923f6050d9ca941
parent 38713 6b5deb20d5eef11e3f46d3c048949d5a324d5de1
child 38715 f4d8df2faceaaa11bc8f951b6a772acd10d7e525
push id400
push userclokep@gmail.com
push dateMon, 04 May 2020 18:56:09 +0000
reviewersdarktrojan, wsmwk
bugs1631184
Bug 1631184 - Marking messages as read or flagged with browser.messages.update fails to persist for IMAP folders. r=darktrojan a=wsmwk
mail/components/extensions/parent/ext-messages.js
--- a/mail/components/extensions/parent/ext-messages.js
+++ b/mail/components/extensions/parent/ext-messages.js
@@ -341,43 +341,43 @@ this.messages = class extends ExtensionA
             context.extension
           );
         },
         async update(messageId, newProperties) {
           let msgHdr = messageTracker.getMessage(messageId);
           if (!msgHdr) {
             return;
           }
+          const msgs = Cc["@mozilla.org/array;1"].createInstance(
+            Ci.nsIMutableArray
+          );
+          msgs.appendElement(msgHdr);
+
           if (newProperties.read !== null) {
-            msgHdr.markRead(newProperties.read);
+            msgHdr.folder.markMessagesRead(msgs, newProperties.read);
           }
           if (newProperties.flagged !== null) {
-            msgHdr.markFlagged(newProperties.flagged);
+            msgHdr.folder.markMessagesFlagged(msgs, newProperties.flagged);
           }
           if (newProperties.junk !== null) {
-            let messages = Cc["@mozilla.org/array;1"].createInstance(
-              Ci.nsIMutableArray
-            );
             let score = newProperties.junk
               ? Ci.nsIJunkMailPlugin.IS_SPAM_SCORE
               : Ci.nsIJunkMailPlugin.IS_HAM_SCORE;
-            messages.appendElement(msgHdr);
-            msgHdr.folder.setJunkScoreForMessages(messages, score);
+            msgHdr.folder.setJunkScoreForMessages(msgs, score);
           }
           if (Array.isArray(newProperties.tags)) {
             let currentTags = msgHdr.getStringProperty("keywords").split(" ");
-            let msgHdrArray = toXPCOMArray([msgHdr], Ci.nsIMutableArray);
 
             for (let { key: tagKey } of MailServices.tags.getAllTags()) {
               if (newProperties.tags.includes(tagKey)) {
                 if (!currentTags.includes(tagKey)) {
-                  msgHdr.folder.addKeywordsToMessages(msgHdrArray, tagKey);
+                  msgHdr.folder.addKeywordsToMessages(msgs, tagKey);
                 }
               } else if (currentTags.includes(tagKey)) {
-                msgHdr.folder.removeKeywordsFromMessages(msgHdrArray, tagKey);
+                msgHdr.folder.removeKeywordsFromMessages(msgs, tagKey);
               }
             }
           }
         },
         async move(messageIds, destination) {
           return moveOrCopyMessages(messageIds, destination, true);
         },
         async copy(messageIds, destination) {