Refactor watermark handling and improve tab switching logic for enhanced user experience

This commit is contained in:
mr. M
2025-02-21 18:37:53 +01:00
parent 68cf549df3
commit df597e6452
7 changed files with 71 additions and 46 deletions

View File

@@ -107,7 +107,6 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
}
selectEmptyTab() {
console.log(new Error().stack);
if (this._emptyTab && Services.prefs.getBoolPref('zen.urlbar.replace-newtab')) {
gBrowser.selectedTab = this._emptyTab;
return this._emptyTab;
@@ -2227,6 +2226,13 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
return this._allStoredTabs;
}
get allUsedBrowsers() {
if (!this._hasInitializedTabsStrip) {
return gBrowser.browsers;
}
return Array.from(gBrowser.tabpanels.querySelectorAll('browser'));
}
get pinnedTabCount() {
return this.pinnedTabsContainer.children.length - 1;
}
@@ -2245,4 +2251,12 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
this.moveTabToWorkspace(tab, this.activeWorkspace);
}
}
switchIfNeeded(browser) {
const tab = gBrowser.getTabForBrowser(browser);
const workspaceId = tab.getAttribute('zen-workspace-id');
if (!tab.hasAttribute('zen-essential') && workspaceId !== this.activeWorkspace) {
this.changeWorkspace({ uuid: workspaceId });
}
}
})();