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

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

@ -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);
});
}

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

@ -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"