Bug 1823182 - Fix the View toolbar button. r=freaktechnik

Differential Revision: https://phabricator.services.mozilla.com/D180294

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Geoff Lankow 2023-06-08 09:37:24 +00:00
Родитель d0f4b2c189
Коммит 01aa4c9df3
3 изменённых файлов: 51 добавлений и 21 удалений

Просмотреть файл

@ -93,13 +93,16 @@
onpopupshowing="RefreshViewPopup(this);"> onpopupshowing="RefreshViewPopup(this);">
<menuitem id="viewPickerAll" value="0" <menuitem id="viewPickerAll" value="0"
label="&viewAll.label;" label="&viewAll.label;"
type="radio"/> type="radio"
oncommand="ViewChangeByMenuitem(this);"/>
<menuitem id="viewPickerUnread" value="1" <menuitem id="viewPickerUnread" value="1"
label="&viewUnread.label;" label="&viewUnread.label;"
type="radio"/> type="radio"
oncommand="ViewChangeByMenuitem(this);"/>
<menuitem id="viewPickerNotDeleted" value="3" <menuitem id="viewPickerNotDeleted" value="3"
label="&viewNotDeleted.label;" label="&viewNotDeleted.label;"
type="radio"/> type="radio"
oncommand="ViewChangeByMenuitem(this);"/>
<menuseparator id="afterViewPickerUnreadSeparator"/> <menuseparator id="afterViewPickerUnreadSeparator"/>
<menu id="viewPickerTags" label="&viewTags.label;"> <menu id="viewPickerTags" label="&viewTags.label;">
<menupopup id="viewPickerTagsPopup" <menupopup id="viewPickerTagsPopup"
@ -114,10 +117,12 @@
<menuseparator id="afterViewPickerCustomViewsSeparator"/> <menuseparator id="afterViewPickerCustomViewsSeparator"/>
<menuitem id="viewPickerVirtualFolder" <menuitem id="viewPickerVirtualFolder"
value="7" value="7"
label="&viewVirtualFolder.label;"/> label="&viewVirtualFolder.label;"
oncommand="ViewChangeByMenuitem(this);"/>
<menuitem id="viewPickerCustomize" <menuitem id="viewPickerCustomize"
value="8" value="8"
label="&viewCustomizeView.label;"/> label="&viewCustomizeView.label;"
oncommand="ViewChangeByMenuitem(this);"/>
</menupopup> </menupopup>
<menupopup id="messageHistoryPopup"> <menupopup id="messageHistoryPopup">
</menupopup> </menupopup>

Просмотреть файл

@ -2,8 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// TODO: Fix undefined things in this file. /* globals OpenOrFocusWindow */ // From mailWindowOverlay.js
/* eslint-disable no-undef */ /* globals GetSelectedMsgFolders */ // From messenger.js
var { MailServices } = ChromeUtils.import( var { MailServices } = ChromeUtils.import(
"resource:///modules/MailServices.jsm" "resource:///modules/MailServices.jsm"
@ -36,15 +36,21 @@ var gMailViewList = null;
// perform the view/action requested by the aValue string // perform the view/action requested by the aValue string
// and set the view picker label to the aLabel string // and set the view picker label to the aLabel string
function ViewChange(aValue) { function ViewChange(aValue) {
let about3Pane = document.getElementById("tabmail").currentAbout3Pane;
let viewWrapper = about3Pane.gViewWrapper;
if (!viewWrapper) {
return;
}
if (aValue == kViewItemCustomize || aValue == kViewItemVirtual) { if (aValue == kViewItemCustomize || aValue == kViewItemVirtual) {
// restore to the previous view value, in case they cancel // restore to the previous view value, in case they cancel
ViewPickerBinding.updateDisplay(); ViewPickerBinding.updateDisplay();
if (aValue == kViewItemCustomize) { if (aValue == kViewItemCustomize) {
LaunchCustomizeDialog(); LaunchCustomizeDialog();
} else { } else {
gFolderTreeController.newVirtualFolder( about3Pane.folderPane.newVirtualFolder(
ViewPickerBinding.currentViewLabel, ViewPickerBinding.currentViewLabel,
gFolderDisplay.view.search.viewTerms viewWrapper.search.viewTerms
); );
} }
return; return;
@ -54,10 +60,10 @@ function ViewChange(aValue) {
if (isNaN(aValue)) { if (isNaN(aValue)) {
// split off the tag key // split off the tag key
var tagkey = aValue.substr(kViewTagMarker.length); var tagkey = aValue.substr(kViewTagMarker.length);
gFolderDisplay.view.setMailView(kViewItemTags, tagkey); viewWrapper.setMailView(kViewItemTags, tagkey);
} else { } else {
var numval = Number(aValue); var numval = Number(aValue);
gFolderDisplay.view.setMailView(numval, null); viewWrapper.setMailView(numval, null);
} }
ViewPickerBinding.updateDisplay(); ViewPickerBinding.updateDisplay();
} }
@ -96,18 +102,24 @@ var ViewPickerBinding = {
* everything but tags. for tags it's the ":"-prefixed tagname. * everything but tags. for tags it's the ":"-prefixed tagname.
*/ */
get currentViewValue() { get currentViewValue() {
if (gFolderDisplay.view.mailViewIndex == kViewItemTags) { let about3Pane = document.getElementById("tabmail").currentAbout3Pane;
return kViewTagMarker + gFolderDisplay.view.mailViewData; 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. * @returns The label for the current mail view value.
*/ */
get currentViewLabel() { get currentViewLabel() {
let viewPicker = document.getElementById("viewPicker"); return document.querySelector(
return viewPicker.getAttribute("label"); `#toolbarViewPickerPopup [value="${this.currentViewValue}"]`
)?.label;
}, },
/** /**
@ -242,6 +254,11 @@ function RefreshCustomViewsPopup(parent, elementName = "menuitem", classes) {
if (kViewItemFirstCustom + i == currentView) { if (kViewItemFirstCustom + i == currentView) {
item.setAttribute("checked", true); item.setAttribute("checked", true);
} }
item.addEventListener("command", () =>
ViewChange(kViewItemFirstCustom + i)
);
parent.appendChild(item); parent.appendChild(item);
} }
} }
@ -261,10 +278,13 @@ function RefreshTagsPopup(parent, elementName = "menuitem", classes) {
} }
// Create tag menu items. // Create tag menu items.
let about3Pane = document.getElementById("tabmail").currentAbout3Pane;
let viewWrapper = about3Pane.gViewWrapper;
if (!viewWrapper) {
return;
}
const currentTagKey = const currentTagKey =
gFolderDisplay.view.mailViewIndex == kViewItemTags viewWrapper.mailViewIndex == kViewItemTags ? viewWrapper.mailViewData : "";
? gFolderDisplay.view.mailViewData
: "";
const tagArray = MailServices.tags.getAllTags(); const tagArray = MailServices.tags.getAllTags();
@ -284,6 +304,11 @@ function RefreshTagsPopup(parent, elementName = "menuitem", classes) {
if (classes) { if (classes) {
item.setAttribute("class", classes); item.setAttribute("class", classes);
} }
item.addEventListener("command", () =>
ViewChange(kViewTagMarker + tagInfo.key)
);
parent.appendChild(item); parent.appendChild(item);
}); });
} }

Просмотреть файл

@ -1,9 +1,9 @@
version="8" version="9"
logging="no" logging="no"
name="People I Know" name="People I Know"
enabled="yes" enabled="yes"
type="1" type="1"
condition="AND (from,is in ab,moz-abmdbdirectory://abook.mab)" condition="AND (from,is in ab,jsaddrbook://abook.sqlite)"
name="Recent Mail" name="Recent Mail"
enabled="yes" enabled="yes"
type="1" type="1"