chore: Add onLocationChange method to ZenWorkspaces

This commit is contained in:
Mauro Balades
2024-07-13 20:53:46 +02:00
parent aa812d1fea
commit 0a34fb4fb0
3 changed files with 31 additions and 6 deletions

View File

@@ -242,6 +242,19 @@ var ZenWorkspaces = {
await this.saveWorkspace(workspaceData);
await this.changeWorkspace(workspaceData);
},
async onLocationChange(browser) {
let tab = gBrowser.getTabForBrowser(browser);
let workspaceID = tab.getAttribute("zen-workspace-id");
if (!workspaceID) {
let workspaces = await this._workspaces();
let activeWorkspace = workspaces.workspaces.find(workspace => workspace.used);
if (!activeWorkspace) {
return;
}
tab.setAttribute("zen-workspace-id", activeWorkspace.uuid);
}
},
};
ZenWorkspaces.init();

View File

@@ -1,5 +1,5 @@
diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js
index 5f41ca778131eedfd32043dc27d6528be978c4fb..086b01e8fdf80dd333d80b9eede190cdb5315b70 100644
index b18f371a47fec53882c3dfb68e34d1a474eaf446..2c183d7e7fc65e00403f5e40e7859b915a3ea700 100644
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -630,6 +630,15 @@ XPCOMUtils.defineLazyPreferenceGetter(
@@ -18,16 +18,17 @@ index 5f41ca778131eedfd32043dc27d6528be978c4fb..086b01e8fdf80dd333d80b9eede190cd
customElements.setElementCreationCallback("screenshots-buttons", () => {
Services.scriptloader.loadSubScript(
"chrome://browser/content/screenshots/screenshots-buttons.js",
@@ -3668,6 +3677,8 @@ var XULBrowserWindow = {
@@ -3679,6 +3688,9 @@ var XULBrowserWindow = {
AboutReaderParent.updateReaderButton(gBrowser.selectedBrowser);
TranslationsParent.onLocationChange(gBrowser.selectedBrowser);
+ gZenViewSplitter.onLocationChange(gBrowser.selectedBrowser);
+ ZenWorkspaces.onLocationChange(gBrowser.selectedBrowser);
+
PictureInPicture.updateUrlbarToggle(gBrowser.selectedBrowser);
if (!gMultiProcessBrowser) {
@@ -4982,7 +4993,7 @@ function setToolbarVisibility(
@@ -5001,7 +5013,7 @@ function setToolbarVisibility(
);
}
@@ -36,7 +37,7 @@ index 5f41ca778131eedfd32043dc27d6528be978c4fb..086b01e8fdf80dd333d80b9eede190cd
switch (isVisible) {
case true:
case "always":
@@ -7813,6 +7824,12 @@ var gDialogBox = {
@@ -7832,6 +7844,12 @@ var gDialogBox = {
parentElement.showModal();
this._didOpenHTMLDialog = true;

View File

@@ -1,5 +1,5 @@
diff --git a/browser/components/tabbrowser/content/tabbrowser.js b/browser/components/tabbrowser/content/tabbrowser.js
index 2674dc2bebf436529a46d45c52cb56e86b82c03f..c70801bed55e0182eb56e9fd7bea5be9986c7120 100644
index 2674dc2bebf436529a46d45c52cb56e86b82c03f..960c0039cd511a9d2c78e2a0c8c78080464950ee 100644
--- a/browser/components/tabbrowser/content/tabbrowser.js
+++ b/browser/components/tabbrowser/content/tabbrowser.js
@@ -3208,6 +3208,11 @@
@@ -14,7 +14,18 @@ index 2674dc2bebf436529a46d45c52cb56e86b82c03f..c70801bed55e0182eb56e9fd7bea5be9
if (!tabData.pinned) {
this.unpinTab(tab);
} else {
@@ -7878,6 +7883,11 @@ var TabContextMenu = {
@@ -3257,6 +3262,10 @@
preferredRemoteType,
});
+ if (tabData.zenWorkspace) {
+ tab.setAttribute("zen-workspace-id", tabData.zenWorkspace);
+ }
+
if (select) {
tabToSelect = tab;
}
@@ -7878,6 +7887,11 @@ var TabContextMenu = {
this.contextTab.linkedBrowser,
document.getElementById("context_sendTabToDevice")
);