From 28e97bbf7beed0fa10bdb7fc39ed9d866a6643cd Mon Sep 17 00:00:00 2001 From: Jorg Knobloch Date: Wed, 22 Apr 2020 20:13:43 +0200 Subject: [PATCH] Another installment in the never ending Re: processing litany. --- chrome/content/TbHelper.js | 6 ++---- chrome/content/TbMessageView.js | 18 ++++++++---------- chrome/content/pepmessengercompose.js | 6 +++--- 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/chrome/content/TbHelper.js b/chrome/content/TbHelper.js index e6197cb..9dd1dd7 100644 --- a/chrome/content/TbHelper.js +++ b/chrome/content/TbHelper.js @@ -11,10 +11,8 @@ const TbHelper = { copyMessageToFolder(msgHdr, newSubject, content) { // Setting the subject here to the version where the Re: prefix was removed, // as returned from `updateSubject()`, seems to have a positive effect. - // This is the result of quite some experimentation. In reality - // this appears to be another workaround for - // https://bugzilla.mozilla.org/show_bug.cgi?id=1629555 - // as the correct subject should have already been stored in that function. + // This is the result of quite some experimentation. + // Ideally the correct subject should have already been stored in that function. if (newSubject) msgHdr.subject = newSubject; // Copy copied form Header Tools Lite. There is a variation in Enigmail. diff --git a/chrome/content/TbMessageView.js b/chrome/content/TbMessageView.js index 71ebd82..cd3b8c9 100644 --- a/chrome/content/TbMessageView.js +++ b/chrome/content/TbMessageView.js @@ -23,7 +23,8 @@ const TbMessageView = { } for (let p of prefixes) { let regEx = new RegExp(`^(${p}: )+`, "i"); - subject = subject.replace(regEx, ""); // Remove prefix. + // Remove prefix. + subject = subject.replace(regEx, ""); } let hadRe = (subject != content); @@ -33,22 +34,19 @@ const TbMessageView = { // The database doesn't like raw UTF apparently. subject = jsmime.headeremitter.emitStructuredHeader("subject", subject, {}).substring(9); - // We should store the subject without any Re: prefix, but - // https://bugzilla.mozilla.org/show_bug.cgi?id=1629555 - // gets in the way. So the correct code is commented out for now. - // Correct would be these two lines ... - // if (hadRe) msgHdr.flags |= Ci.nsMsgMessageFlags.HasRe; - // msgHdr.subject = subject; - // ... and replace the if-else below. if (msgHdr.flags & Ci.nsMsgMessageFlags.HasRe) { // If the flag is already set, we can just store the subject. msgHdr.subject = subject; } else { - // This is WRONG. Should not prepend "Re: " but instead set the flag. See above. + // It would be nice to store the subject without the "Re:" prefix and set + // the HasRe flag instead. That works when calling + // tree.view.db.NotifyHdrChangeAll(msgHdr, msgHdr.flags | Ci.nsMsgMessageFlags.HasRe, msgHdr.flags, {}); + // but sadly the solution falls apart when copying messages between + // IMAP folders or between local and IMAP folders. // eslint-disable-next-line prefer-template msgHdr.subject = hadRe ? "Re: " + subject : subject; } - if (tree) tree.invalidate(); + if (tree && tree.view && tree.view.selection) tree.invalidateRow(tree.view.selection.currentIndex); return subject; }, diff --git a/chrome/content/pepmessengercompose.js b/chrome/content/pepmessengercompose.js index db87530..c1f337b 100644 --- a/chrome/content/pepmessengercompose.js +++ b/chrome/content/pepmessengercompose.js @@ -235,9 +235,9 @@ var pEpComposer = { }; } - // Workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=1629555 - // that doesn't allow us to correctly store the HasRe flag. - // So now we need to fix the side effects :-( + // Workaround for the fact that some messages have a "Re:" stored + // in the subject and don't have the HasRe flag set. In that case + // we receive a doubled up "Re:". let subjElem = document.getElementById("msgSubject"); if (subjElem) { let prefixes = Services.prefs.getStringPref("mailnews.localizedRe", "");