feat: Listen for tabHide and tabShow events for window sync, b=bug #12408, c=no-component

This commit is contained in:
mr. m
2026-02-19 00:50:11 +01:00
parent a30ddc98bd
commit a8e245b28a

View File

@@ -47,6 +47,9 @@ const EVENTS = [
"TabGroupRemoved",
"TabGroupMoved",
"TabHide",
"TabShow",
"ZenTabRemovedFromSplit",
"ZenSplitViewTabsSplit",
@@ -1167,6 +1170,34 @@ class nsZenWindowSync {
return this.#delegateGenericSyncEvent(aEvent, SYNC_FLAG_LABEL);
}
on_TabHide(aEvent) {
const tab = aEvent.target;
const window = tab.ownerGlobal;
if (lazy.gSyncOnlyPinnedTabs && !tab.pinned) {
return;
}
this.#runOnAllWindows(window, (win) => {
const targetTab = this.getItemFromWindow(win, tab.id);
if (targetTab) {
targetTab.ownerGlobal.gBrowser.hideTab(targetTab);
}
});
}
on_TabShow(aEvent) {
const tab = aEvent.target;
const window = tab.ownerGlobal;
if (lazy.gSyncOnlyPinnedTabs && !tab.pinned) {
return;
}
this.#runOnAllWindows(window, (win) => {
const targetTab = this.getItemFromWindow(win, tab.id);
if (targetTab) {
targetTab.ownerGlobal.gBrowser.showTab(targetTab);
}
});
}
on_TabMove(aEvent) {
this.#delegateGenericSyncEvent(aEvent, SYNC_FLAG_MOVE);
return Promise.resolve();