mirror of
https://github.com/zen-browser/desktop.git
synced 2025-10-08 19:06:38 +00:00
Refactor ZenWorkspaces to enhance tab switching logic with asynchronous handling for improved workspace management
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js
|
diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js
|
||||||
index 019b168c1aeae7e1c97a3ae58c99a48a27f54134..56ed0bffb0ec0863c18ef881acb4efcc590e4a96 100644
|
index 019b168c1aeae7e1c97a3ae58c99a48a27f54134..89045fd46888d2a15ccee1b35ed83692faaad364 100644
|
||||||
--- a/browser/base/content/browser.js
|
--- a/browser/base/content/browser.js
|
||||||
+++ b/browser/base/content/browser.js
|
+++ b/browser/base/content/browser.js
|
||||||
@@ -32,6 +32,7 @@ ChromeUtils.defineESModuleGetters(this, {
|
@@ -32,6 +32,7 @@ ChromeUtils.defineESModuleGetters(this, {
|
||||||
@@ -51,11 +51,13 @@ index 019b168c1aeae7e1c97a3ae58c99a48a27f54134..56ed0bffb0ec0863c18ef881acb4efcc
|
|||||||
for (let i = 0; i < browsers.length; i++) {
|
for (let i = 0; i < browsers.length; i++) {
|
||||||
let browser = browsers[i];
|
let browser = browsers[i];
|
||||||
let browserCompare = cleanURL(
|
let browserCompare = cleanURL(
|
||||||
@@ -6364,6 +6374,7 @@ function switchToTabHavingURI(
|
@@ -6392,7 +6402,9 @@ function switchToTabHavingURI(
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
if (requestedCompare == browserCompare) {
|
|
||||||
+ aWindow.ZenWorkspaces.switchIfNeeded(browser);
|
if (!doAdopt) {
|
||||||
// If adoptIntoActiveWindow is set, and this is a cross-window switch,
|
+ aWindow.ZenWorkspaces.switchIfNeeded(browser).then(() => {
|
||||||
// adopt the tab into the current window, after the active tab.
|
aWindow.gBrowser.tabContainer.selectedIndex = i;
|
||||||
let doAdopt =
|
+ });
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
@@ -2273,10 +2273,13 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
|
|||||||
}
|
}
|
||||||
|
|
||||||
switchIfNeeded(browser) {
|
switchIfNeeded(browser) {
|
||||||
|
return new Promise(async(resolve) => {
|
||||||
const tab = gBrowser.getTabForBrowser(browser);
|
const tab = gBrowser.getTabForBrowser(browser);
|
||||||
const workspaceId = tab.getAttribute('zen-workspace-id');
|
const workspaceId = tab.getAttribute('zen-workspace-id');
|
||||||
if (!tab.hasAttribute('zen-essential') && workspaceId !== this.activeWorkspace) {
|
if (!tab.hasAttribute('zen-essential') && workspaceId !== this.activeWorkspace) {
|
||||||
this.changeWorkspace({ uuid: workspaceId });
|
await this.changeWorkspace({ uuid: workspaceId });
|
||||||
}
|
}
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
Reference in New Issue
Block a user