mirror of
https://github.com/zen-browser/desktop.git
synced 2026-07-17 22:21:04 +00:00
feat: Listen for tabHide and tabShow events for window sync, b=bug #12408, c=no-component
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user