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