mirror of
https://github.com/zen-browser/desktop.git
synced 2025-10-08 10:56:36 +00:00
Refactor tab selection logic in ZenWorkspaces to improve clarity and maintainability
This commit is contained in:
@@ -1689,6 +1689,10 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
|
|||||||
return tabWorkspaceId === workspaceUuid;
|
return tabWorkspaceId === workspaceUuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_shouldChangeToTab(aTab) {
|
||||||
|
return !(aTab.hasAttribute('zen-essential') || (aTab.pinned && aTab.hasAttribute('pending')));
|
||||||
|
}
|
||||||
|
|
||||||
async _handleTabSelection(window, onInit, containerId, workspaces, previousWorkspaceId, prevTabUsed) {
|
async _handleTabSelection(window, onInit, containerId, workspaces, previousWorkspaceId, prevTabUsed) {
|
||||||
const currentSelectedTab = prevTabUsed || gBrowser.selectedTab;
|
const currentSelectedTab = prevTabUsed || gBrowser.selectedTab;
|
||||||
const oldWorkspaceId = previousWorkspaceId;
|
const oldWorkspaceId = previousWorkspaceId;
|
||||||
@@ -1710,7 +1714,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
|
|||||||
if (!tabToSelect && gBrowser.visibleTabs.length) {
|
if (!tabToSelect && gBrowser.visibleTabs.length) {
|
||||||
tabToSelect = gBrowser.visibleTabs[gBrowser.visibleTabs.length - 1];
|
tabToSelect = gBrowser.visibleTabs[gBrowser.visibleTabs.length - 1];
|
||||||
}
|
}
|
||||||
if (tabToSelect?.hasAttribute('zen-essential') || (tabToSelect?.pinned && tabToSelect?.hasAttribute('pending'))) {
|
if (!tabToSelect || !this._shouldChangeToTab(tabToSelect)) {
|
||||||
// Never select an essential tab
|
// Never select an essential tab
|
||||||
tabToSelect = null;
|
tabToSelect = null;
|
||||||
}
|
}
|
||||||
@@ -2021,7 +2025,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
|
|||||||
}
|
}
|
||||||
|
|
||||||
findTabToBlur(tab) {
|
findTabToBlur(tab) {
|
||||||
return tab.hasAttribute('zen-essential') && this._emptyTab ? this._emptyTab : tab;
|
return !this._shouldChangeToTab(tab) && this._emptyTab ? this._emptyTab : tab;
|
||||||
}
|
}
|
||||||
|
|
||||||
async setDefaultWorkspace() {
|
async setDefaultWorkspace() {
|
||||||
|
Reference in New Issue
Block a user