mirror of
https://github.com/zen-browser/desktop.git
synced 2025-10-07 02:16:36 +00:00
Refactor workspace settings and improve tab management; remove individual pinned tabs preference, update bootstrap command, and enhance tab removal logic for non-existent workspaces.
This commit is contained in:
@@ -605,6 +605,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
|
||||
this._selectStartPage();
|
||||
this._fixTabPositions();
|
||||
this._resolveInitialized();
|
||||
this._clearAnyZombieTabs(); // Dont call with await
|
||||
}
|
||||
}
|
||||
|
||||
@@ -652,6 +653,26 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
|
||||
return !window.toolbar.visible || Services.prefs.getBoolPref('browser.tabs.closeWindowWithLastTab');
|
||||
}
|
||||
|
||||
async _clearAnyZombieTabs() {
|
||||
const tabs = this.allStoredTabs;
|
||||
const workspaces = await this._workspaces();
|
||||
for (let tab of tabs) {
|
||||
const workspaceID = tab.getAttribute('zen-workspace-id');
|
||||
if (
|
||||
workspaceID &&
|
||||
!tab.hasAttribute('zen-essential') &&
|
||||
!workspaces.workspaces.find((workspace) => workspace.uuid === workspaceID)
|
||||
) {
|
||||
// Remove any tabs where their workspace doesn't exist anymore
|
||||
gBrowser.removeTab(tab, {
|
||||
animate: false,
|
||||
skipSessionStore: true,
|
||||
closeWindowWithLastTab: false,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
handleTabBeforeClose(tab) {
|
||||
if (!this.workspaceEnabled || this.__contextIsDelete || this._removedByStartupPage) {
|
||||
return null;
|
||||
@@ -1382,10 +1403,10 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
|
||||
}
|
||||
|
||||
_deleteAllTabsInWorkspace(workspaceID) {
|
||||
for (let tab of gBrowser.tabs) {
|
||||
for (let tab of this.allStoredTabs) {
|
||||
if (tab.getAttribute('zen-workspace-id') === workspaceID) {
|
||||
gBrowser.removeTab(tab, {
|
||||
animate: true,
|
||||
animate: false,
|
||||
skipSessionStore: true,
|
||||
closeWindowWithLastTab: false,
|
||||
});
|
||||
@@ -1508,12 +1529,12 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
|
||||
const previousWorkspace = await this.getActiveWorkspace();
|
||||
alwaysChange = alwaysChange || onInit;
|
||||
|
||||
this.activeWorkspace = window.uuid;
|
||||
if (previousWorkspace && previousWorkspace.uuid === window.uuid && !alwaysChange) {
|
||||
this._cancelSwipeAnimation();
|
||||
return;
|
||||
}
|
||||
|
||||
this.activeWorkspace = window.uuid;
|
||||
const containerId = window.containerTabId?.toString();
|
||||
const workspaces = await this._workspaces();
|
||||
|
||||
@@ -1995,6 +2016,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
|
||||
|
||||
// Switch workspace if needed
|
||||
if (workspaceID && workspaceID !== activeWorkspace.uuid && parent.ZenWorkspaces._hasInitializedTabsStrip) {
|
||||
const workspaces = await parent.ZenWorkspaces._workspaces();
|
||||
await parent.ZenWorkspaces.changeWorkspace({ uuid: workspaceID });
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user