Bug 1718605 - Fix active mode of calendar UI during account set-up. r=mkmelin

This makes two changes:
* When a tab monitor is registered, its onTabSwitched method is now called immediately with the current tab, so that its state can match the current tab at the time of registration.
* When calendar starts up, which may be during the account set-up process, the UI is not put in the "mail" mode if the account set-up tab (or other content tab) is open. Instead the "special" mode is used, which is the right mode for content tabs.

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

--HG--
extra : rebase_source : 0b9502893d078ecfeb3bd5462f8895f11c509a5d
This commit is contained in:
Geoff Lankow 2021-06-29 21:32:44 +12:00
Родитель 6eedf0373f
Коммит 113e4ee5b8
3 изменённых файлов: 15 добавлений и 4 удалений

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

@ -127,7 +127,14 @@ async function loadCalendarComponent() {
filter.value = filter.value || "all";
// Set up mode-switching menu items and mode[v]box elements for the initial mode.
changeMode();
// At this point no tabs have been restored, so the only reason we wouldn't be
// in "mail" mode is if a content tab has opened to display the account set-up.
let tabmail = document.getElementById("tabmail");
if (tabmail.currentTabInfo.mode.name == "contentTab") {
changeMode("special");
} else {
changeMode("mail");
}
// Set up customizeDone handlers for our toolbars.
let toolbox = document.getElementById("calendar-toolbox");

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

@ -421,8 +421,9 @@
* used in the course of wrapping the object.
* The following functions should be provided on the monitor object:
* * onTabTitleChanged(aTab): Called when the tab's title changes.
* * onTabSwitched(aTab, aOldTab): Called when a new tab is made active. If
* this is the first tab ever, aOldTab will be null, otherwise aOldTab
* * onTabSwitched(aTab, aOldTab): Called when a new tab is made active.
* Also called when the monitor is registered if one or more tabs exist.
* If this is the first call, aOldTab will be null, otherwise aOldTab
* will be the previously active tab.
* * onTabOpened(aTab, aIsFirstTab, aWasCurrentTab): Called when a new tab is
* opened. This method is invoked after the tab mode's openTab method
@ -709,6 +710,9 @@
registerTabMonitor(aTabMonitor) {
if (!this.tabMonitors.includes(aTabMonitor)) {
this.tabMonitors.push(aTabMonitor);
if (this.tabInfo.length) {
aTabMonitor.onTabSwitched(this.currentTabInfo, null);
}
}
}

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

@ -249,7 +249,7 @@ var chatTabType = {
},
onTabSwitched(aNewTab, aOldTab) {
// aNewTab == chat is handled earlier by showTab() below.
if (aOldTab.mode.name == "chat") {
if (aOldTab?.mode.name == "chat") {
chatHandler._onTabDeactivated(true);
}
},