diff --git a/mail/components/unifiedtoolbar/content/unifiedToolbarPopups.inc.xhtml b/mail/components/unifiedtoolbar/content/unifiedToolbarPopups.inc.xhtml index 718c6b3c99..531069507d 100644 --- a/mail/components/unifiedtoolbar/content/unifiedToolbarPopups.inc.xhtml +++ b/mail/components/unifiedtoolbar/content/unifiedToolbarPopups.inc.xhtml @@ -93,13 +93,16 @@ onpopupshowing="RefreshViewPopup(this);"> + type="radio" + oncommand="ViewChangeByMenuitem(this);"/> + type="radio" + oncommand="ViewChangeByMenuitem(this);"/> + type="radio" + oncommand="ViewChangeByMenuitem(this);"/> + label="&viewVirtualFolder.label;" + oncommand="ViewChangeByMenuitem(this);"/> + label="&viewCustomizeView.label;" + oncommand="ViewChangeByMenuitem(this);"/> diff --git a/mail/extensions/mailviews/content/msgViewPickerOverlay.js b/mail/extensions/mailviews/content/msgViewPickerOverlay.js index 86bd373ba5..bc1a775a3f 100644 --- a/mail/extensions/mailviews/content/msgViewPickerOverlay.js +++ b/mail/extensions/mailviews/content/msgViewPickerOverlay.js @@ -2,8 +2,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -// TODO: Fix undefined things in this file. -/* eslint-disable no-undef */ +/* globals OpenOrFocusWindow */ // From mailWindowOverlay.js +/* globals GetSelectedMsgFolders */ // From messenger.js var { MailServices } = ChromeUtils.import( "resource:///modules/MailServices.jsm" @@ -36,15 +36,21 @@ var gMailViewList = null; // perform the view/action requested by the aValue string // and set the view picker label to the aLabel string function ViewChange(aValue) { + let about3Pane = document.getElementById("tabmail").currentAbout3Pane; + let viewWrapper = about3Pane.gViewWrapper; + if (!viewWrapper) { + return; + } + if (aValue == kViewItemCustomize || aValue == kViewItemVirtual) { // restore to the previous view value, in case they cancel ViewPickerBinding.updateDisplay(); if (aValue == kViewItemCustomize) { LaunchCustomizeDialog(); } else { - gFolderTreeController.newVirtualFolder( + about3Pane.folderPane.newVirtualFolder( ViewPickerBinding.currentViewLabel, - gFolderDisplay.view.search.viewTerms + viewWrapper.search.viewTerms ); } return; @@ -54,10 +60,10 @@ function ViewChange(aValue) { if (isNaN(aValue)) { // split off the tag key var tagkey = aValue.substr(kViewTagMarker.length); - gFolderDisplay.view.setMailView(kViewItemTags, tagkey); + viewWrapper.setMailView(kViewItemTags, tagkey); } else { var numval = Number(aValue); - gFolderDisplay.view.setMailView(numval, null); + viewWrapper.setMailView(numval, null); } ViewPickerBinding.updateDisplay(); } @@ -96,18 +102,24 @@ var ViewPickerBinding = { * everything but tags. for tags it's the ":"-prefixed tagname. */ get currentViewValue() { - if (gFolderDisplay.view.mailViewIndex == kViewItemTags) { - return kViewTagMarker + gFolderDisplay.view.mailViewData; + let about3Pane = document.getElementById("tabmail").currentAbout3Pane; + let viewWrapper = about3Pane.gViewWrapper; + if (!viewWrapper) { + return ""; } - return gFolderDisplay.view.mailViewIndex + ""; + if (viewWrapper.mailViewIndex == kViewItemTags) { + return kViewTagMarker + viewWrapper.mailViewData; + } + return viewWrapper.mailViewIndex + ""; }, /** * @returns The label for the current mail view value. */ get currentViewLabel() { - let viewPicker = document.getElementById("viewPicker"); - return viewPicker.getAttribute("label"); + return document.querySelector( + `#toolbarViewPickerPopup [value="${this.currentViewValue}"]` + )?.label; }, /** @@ -242,6 +254,11 @@ function RefreshCustomViewsPopup(parent, elementName = "menuitem", classes) { if (kViewItemFirstCustom + i == currentView) { item.setAttribute("checked", true); } + + item.addEventListener("command", () => + ViewChange(kViewItemFirstCustom + i) + ); + parent.appendChild(item); } } @@ -261,10 +278,13 @@ function RefreshTagsPopup(parent, elementName = "menuitem", classes) { } // Create tag menu items. + let about3Pane = document.getElementById("tabmail").currentAbout3Pane; + let viewWrapper = about3Pane.gViewWrapper; + if (!viewWrapper) { + return; + } const currentTagKey = - gFolderDisplay.view.mailViewIndex == kViewItemTags - ? gFolderDisplay.view.mailViewData - : ""; + viewWrapper.mailViewIndex == kViewItemTags ? viewWrapper.mailViewData : ""; const tagArray = MailServices.tags.getAllTags(); @@ -284,6 +304,11 @@ function RefreshTagsPopup(parent, elementName = "menuitem", classes) { if (classes) { item.setAttribute("class", classes); } + + item.addEventListener("command", () => + ViewChange(kViewTagMarker + tagInfo.key) + ); + parent.appendChild(item); }); } diff --git a/mailnews/extensions/mailviews/mailViews.dat b/mailnews/extensions/mailviews/mailViews.dat index 8565d00612..3c5af3831c 100644 --- a/mailnews/extensions/mailviews/mailViews.dat +++ b/mailnews/extensions/mailviews/mailViews.dat @@ -1,9 +1,9 @@ -version="8" +version="9" logging="no" name="People I Know" enabled="yes" type="1" -condition="AND (from,is in ab,moz-abmdbdirectory://abook.mab)" +condition="AND (from,is in ab,jsaddrbook://abook.sqlite)" name="Recent Mail" enabled="yes" type="1"