This commit is contained in:
mr. M
2025-02-23 10:21:19 +01:00
3 changed files with 17 additions and 11 deletions

View File

@@ -180,7 +180,6 @@
return;
}
const activeTab = gBrowser.selectedTab;
const pinnedTabsByUUID = new Map();
const pinsToCreate = new Set(pins.map((p) => p.uuid));
@@ -295,11 +294,6 @@
newTab.initialize();
}
// Restore active tab
if (!activeTab.closing) {
gBrowser.selectedTab = activeTab;
}
gBrowser._updateTabBarForPinnedTabs();
gZenUIManager.updateTabsToolbar();
}

View File

@@ -128,13 +128,20 @@
class ZenTabUnloader extends ZenDOMOperatedFeature {
static ACTIVITY_MODIFIERS = ['muted', 'soundplaying', 'label', 'attention'];
constructor() {
super();
if (!lazy.zenTabUnloaderEnabled) {
return;
}
this.intervalUnloader = new ZenTabsIntervalUnloader(this);
}
init() {
if (!lazy.zenTabUnloaderEnabled) {
return;
}
this.insertIntoContextMenu();
this.observer = new ZenTabsObserver();
this.intervalUnloader = new ZenTabsIntervalUnloader(this);
this.observer.addTabsListener(this.onTabEvent.bind(this));
}

View File

@@ -599,7 +599,11 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
let showed = false;
if (currentTab.pinned) {
this.selectEmptyTab();
gZenTabUnloader.explicitUnloadTabs([currentTab]);
try {
gZenTabUnloader.explicitUnloadTabs([currentTab]);
} catch (e) {
console.error('ZenWorkspaces: Error unloading tab', e);
}
showed = true;
} else {
const currentTabURL = currentTab.linkedBrowser?.currentURI?.spec;
@@ -1515,7 +1519,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
}
// First pass: Handle tab visibility and workspace ID assignment
const prevTabUsed = this._processTabVisibility(window.uuid, containerId, workspaces);
const prevTabUsed = this._processTabVisibility(window.uuid, containerId, workspaces, onInit);
// Second pass: Handle tab selection
this.tabContainer._invalidateCachedTabs();
@@ -1631,7 +1635,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
this._animatingChange = false;
}
_processTabVisibility(workspaceUuid, containerId, workspaces) {
_processTabVisibility(workspaceUuid, containerId, workspaces, onInit) {
const hiddenTabs = [];
const visibleTabs = gBrowser.tabContainer.visibleTabs;
for (const tab of gBrowser.tabs) {
@@ -1649,7 +1653,8 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
(hiddenTabs.length === visibleTabs.length ||
visibleTabs.every((tab) => tab.getAttribute('zen-essential') === 'true') ||
hiddenTabs.includes(gBrowser.selectedTab)) &&
gZenVerticalTabsManager._canReplaceNewTab
gZenVerticalTabsManager._canReplaceNewTab &&
!onInit
) {
prevTabUsed = gBrowser.selectedTab;
this.selectEmptyTab();