Bug 1829491 - Fix Handling of the Message-ID in the header pane (Clicking on M-ID / context menu: Open M-ID in Browser). r=darktrojan
The open message id functionality was not working. The 102 behavior of using open message pref for how to open that message didn't seem to sane, so the behavior I implemented is slightly different - always open the message in the context it was opened (3pane, tab, or window). Easiest way to test is to set mailnews.headers.showReferences true and move some messages from a conversation to another folder. Then go to the other folder and use the References context menu in the message header. Differential Revision: https://phabricator.services.mozilla.com/D176291 --HG-- extra : rebase_source : 640312e8225aeb9a23aba9bc9c89abf38a7d9bd8
This commit is contained in:
Родитель
7f4e387cb2
Коммит
a3fe69d042
|
@ -3972,6 +3972,10 @@ var messagePane = {
|
|||
messagePane.clearWebPage();
|
||||
messagePane.clearMessages();
|
||||
|
||||
let msgHdr = top.messenger.msgHdrFromURI(messageURI);
|
||||
displayFolder(msgHdr.folder.URI); // Change to correct folder if needed.
|
||||
threadTree.selectedIndex = threadTree.view.findIndexOfMsgHdr(msgHdr, true);
|
||||
|
||||
messageBrowser.contentWindow.displayMessage(messageURI, gViewWrapper);
|
||||
messageBrowser.hidden = false;
|
||||
},
|
||||
|
|
|
@ -3288,26 +3288,20 @@ const gMessageHeader = {
|
|||
let id = event.currentTarget.closest(".header-message-id").id;
|
||||
if (event.button == 0) {
|
||||
// Remove the < and > symbols.
|
||||
window.browsingContext.topChromeWindow.OpenMessageForMessageId(
|
||||
id.substring(1, id.length - 1)
|
||||
);
|
||||
OpenMessageForMessageId(id.substring(1, id.length - 1));
|
||||
}
|
||||
},
|
||||
|
||||
openMessage(event) {
|
||||
let id = event.currentTarget.parentNode.headerField.id;
|
||||
// Remove the < and > symbols.
|
||||
window.browsingContext.topChromeWindow.OpenMessageForMessageId(
|
||||
id.substring(1, id.length - 1)
|
||||
);
|
||||
OpenMessageForMessageId(id.substring(1, id.length - 1));
|
||||
},
|
||||
|
||||
openBrowser(event) {
|
||||
let id = event.currentTarget.parentNode.headerField.id;
|
||||
// Remove the < and > symbols.
|
||||
window.browsingContext.topChromeWindow.OpenBrowserWithMessageId(
|
||||
id.substring(1, id.length - 1)
|
||||
);
|
||||
OpenBrowserWithMessageId(id.substring(1, id.length - 1));
|
||||
},
|
||||
|
||||
copyMessageId(event) {
|
||||
|
@ -3347,7 +3341,7 @@ function MarkSelectedMessagesFlagged(markFlagged) {
|
|||
* Take the message id from the messageIdNode and use the url defined in the
|
||||
* hidden pref "mailnews.messageid_browser.url" to open it in a browser window
|
||||
* (%mid is replaced by the message id).
|
||||
* @param messageId the message id to open
|
||||
* @param {string} messageId - The message id to open.
|
||||
*/
|
||||
function OpenBrowserWithMessageId(messageId) {
|
||||
var browserURL = Services.prefs.getComplexValue(
|
||||
|
@ -3371,47 +3365,36 @@ function OpenBrowserWithMessageId(messageId) {
|
|||
* message in all folders starting with the current selected folder, then the
|
||||
* current account followed by the other accounts and open corresponding
|
||||
* message if found.
|
||||
* @param messageId the message id to open
|
||||
* @param {string} messageId - The message id to open.
|
||||
*/
|
||||
function OpenMessageForMessageId(messageId) {
|
||||
let startServer = gFolder?.server;
|
||||
|
||||
window.setCursor("wait");
|
||||
let { MailUtils } = ChromeUtils.import("resource:///modules/MailUtils.jsm");
|
||||
let messageHeader = MailUtils.getMsgHdrForMsgId(messageId, startServer);
|
||||
let msgHdr = MailUtils.getMsgHdrForMsgId(messageId, startServer);
|
||||
window.setCursor("auto");
|
||||
|
||||
// if message id was found open corresponding message
|
||||
// else show error message
|
||||
if (messageHeader) {
|
||||
OpenMessageByHeader(
|
||||
messageHeader,
|
||||
Services.prefs.getBoolPref("mailnews.messageid.openInNewWindow")
|
||||
);
|
||||
} else {
|
||||
let messageIdStr = "<" + messageId + ">";
|
||||
let bundle = document.getElementById("bundle_messenger");
|
||||
let errorTitle = bundle.getString("errorOpenMessageForMessageIdTitle");
|
||||
let errorMessage = bundle.getFormattedString(
|
||||
"errorOpenMessageForMessageIdMessage",
|
||||
[messageIdStr]
|
||||
);
|
||||
|
||||
Services.prompt.alert(window, errorTitle, errorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
function OpenMessageByHeader(messageHeader, openInNewWindow) {
|
||||
if (openInNewWindow) {
|
||||
window.openDialog(
|
||||
"chrome://messenger/content/messageWindow.xhtml",
|
||||
"_blank",
|
||||
"all,chrome,dialog=no,status,toolbar",
|
||||
messageHeader
|
||||
);
|
||||
} else {
|
||||
// TODO: Reimplement this?
|
||||
// If message was found open corresponding message.
|
||||
if (msgHdr) {
|
||||
let uri = msgHdr.folder.getUriForMsg(msgHdr);
|
||||
let tabmail = top.window.document.getElementById("tabmail");
|
||||
if (tabmail?.currentAbout3Pane) {
|
||||
// Message in 3pane.
|
||||
tabmail.currentAbout3Pane.messagePane.displayMessage(uri);
|
||||
} else {
|
||||
// Message in tab, standalone message window.
|
||||
window.displayMessage(uri);
|
||||
}
|
||||
return;
|
||||
}
|
||||
let messageIdStr = "<" + messageId + ">";
|
||||
let bundle = document.getElementById("bundle_messenger");
|
||||
let errorTitle = bundle.getString("errorOpenMessageForMessageIdTitle");
|
||||
let errorMessage = bundle.getFormattedString(
|
||||
"errorOpenMessageForMessageIdMessage",
|
||||
[messageIdStr]
|
||||
);
|
||||
Services.prompt.alert(window, errorTitle, errorMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -129,16 +129,16 @@ var MailUtils = {
|
|||
* @note Do not use this if you want to open multiple messages at once. Use
|
||||
* |displayMessages| instead.
|
||||
*
|
||||
* @param aMsgHdr the message header to display
|
||||
* @param [aViewWrapperToClone] a view wrapper to clone. If null or not
|
||||
* given, the message header's folder's default
|
||||
* view will be used
|
||||
* @param [aTabmail] a tabmail element to use in case we need to open tabs.
|
||||
* If null or not given:
|
||||
* - if one or more 3pane windows are open, the most recent
|
||||
* one's tabmail is used
|
||||
* - if no 3pane windows are open, a standalone window is
|
||||
* opened instead of a tab
|
||||
* @param {nsIMsgHdr} aMsgHdr - The message header to display.
|
||||
* @param {DBViewWrapper} [aViewWrapperToClone] - A view wrapper to clone.
|
||||
* If null or not given, the message header's folder's default view will
|
||||
* be used.
|
||||
* @param {Element} [aTabmail] - A tabmail element to use in case we need to
|
||||
* open tabs. If null or not given:
|
||||
* - if one or more 3pane windows are open, the most recent one's tabmail
|
||||
* is used, and the window is brought to the front
|
||||
* - if no 3pane windows are open, a standalone window is opened instead
|
||||
* of a tab
|
||||
*/
|
||||
displayMessage(aMsgHdr, aViewWrapperToClone, aTabmail) {
|
||||
this.displayMessages([aMsgHdr], aViewWrapperToClone, aTabmail);
|
||||
|
@ -177,18 +177,17 @@ var MailUtils = {
|
|||
* called when you'd like to display multiple messages to the user according
|
||||
* to the pref set.
|
||||
*
|
||||
* @param aMsgHdrs an array containing the message headers to display. The
|
||||
* array should contain at least one message header
|
||||
* @param [aViewWrapperToClone] a DB view wrapper to clone for each of the
|
||||
* tabs or windows
|
||||
* @param [aTabmail] a tabmail element to use in case we need to open tabs.
|
||||
* If given, the window containing the tabmail is assumed
|
||||
* to be in front. If null or not given:
|
||||
* - if one or more 3pane windows are open, the most recent
|
||||
* one's tabmail is used, and the window is brought to the
|
||||
* front
|
||||
* - if no 3pane windows are open, standalone windows are
|
||||
* opened instead of tabs
|
||||
* @param {nsIMsgHdr[]} aMsgHdrs - An array containing the message headers to
|
||||
* display. The array should contain at least one message header.
|
||||
* @param {DBViewWrapper} [aViewWrapperToClone] - A DB view wrapper to clone
|
||||
* for each of the tabs or windows.
|
||||
* @param {Element} [aTabmail] - A tabmail element to use in case we need to
|
||||
* open tabs. If given, the window containing the tabmail is assumed to be
|
||||
* in front. If null or not given:
|
||||
* - if one or more 3pane windows are open, the most recent one's tabmail
|
||||
* is used, and the window is brought to the front
|
||||
* - if no 3pane windows are open, a standalone window is opened instead
|
||||
* of a tab
|
||||
*/
|
||||
displayMessages(aMsgHdrs, aViewWrapperToClone, aTabmail) {
|
||||
let openMessageBehavior = Services.prefs.getIntPref(
|
||||
|
@ -255,11 +254,11 @@ var MailUtils = {
|
|||
/**
|
||||
* Show this message in an existing window.
|
||||
*
|
||||
* @param aMsgHdr the message header to display
|
||||
* @param [aViewWrapperToClone] a DB view wrapper to clone for the message
|
||||
* window
|
||||
* @returns true if an existing window was found and the message header was
|
||||
* displayed, false otherwise
|
||||
* @param {nsIMsgHdr} aMsgHdr - The message header to display.
|
||||
* @param {DBViewWrapper} [aViewWrapperToClone] - A DB view wrapper to clone
|
||||
* for the message window.
|
||||
* @returns {boolean} true if an existing window was found and the message
|
||||
* header was displayed, false otherwise.
|
||||
*/
|
||||
openMessageInExistingWindow(aMsgHdr, aViewWrapperToClone) {
|
||||
let messageWindow = Services.wm.getMostRecentWindow("mail:messageWindow");
|
||||
|
@ -273,9 +272,9 @@ var MailUtils = {
|
|||
/**
|
||||
* Open a new standalone message window with this header.
|
||||
*
|
||||
* @param aMsgHdr the message header to display
|
||||
* @param [aViewWrapperToClone] a DB view wrapper to clone for the message
|
||||
* window
|
||||
* @param {nsIMsgHdr} aMsgHdr the message header to display
|
||||
* @param {DBViewWrapper} [aViewWrapperToClone] - A DB view wrapper to clone
|
||||
* for the message window.
|
||||
* @returns {DOMWindow} the opened window
|
||||
*/
|
||||
openMessageInNewWindow(aMsgHdr, aViewWrapperToClone) {
|
||||
|
@ -297,9 +296,10 @@ var MailUtils = {
|
|||
* for confirmation if the number of windows to be opened is greater than the
|
||||
* value of the mailnews.open_window_warning preference.
|
||||
*
|
||||
* @param aMsgHdrs an array containing the message headers to display
|
||||
* @param [aViewWrapperToClone] a DB view wrapper to clone for each message
|
||||
* window
|
||||
* @param {nsIMsgHdr[]} aMsgHdrs - An array containing the message headers
|
||||
* to display.
|
||||
* @param {DBViewWrapper} [aViewWrapperToClone] - A DB view wrapper to clone
|
||||
* for each message window.
|
||||
*/
|
||||
openMessagesInNewWindows(aMsgHdrs, aViewWrapperToClone) {
|
||||
if (
|
||||
|
@ -323,7 +323,7 @@ var MailUtils = {
|
|||
* useful when the message needs to be displayed in the context of its folder
|
||||
* or thread.
|
||||
*
|
||||
* @param aMsgHdr the message header to display
|
||||
* @param {nsIMsgHdr} aMsgHdr - The message header to display.
|
||||
*/
|
||||
displayMessageInFolderTab(aMsgHdr) {
|
||||
// Try opening new tabs in a 3pane window
|
||||
|
@ -593,8 +593,8 @@ var MailUtils = {
|
|||
/**
|
||||
* Get the identity for the given header.
|
||||
*
|
||||
* @param hdr nsIMsgHdr message header
|
||||
* @param type nsIMsgCompType compose type the identity is used for.
|
||||
* @param {nsIMsgHdr} hdr - Message header.
|
||||
* @param {nsIMsgCompType} type - Compose type the identity is used for.
|
||||
* @returns {Array} - An array of two elements, [identity, matchingHint].
|
||||
* identity is an nsIMsgIdentity and matchingHint is a string.
|
||||
*/
|
||||
|
|
Загрузка…
Ссылка в новой задаче