feat: Return a copy of workspaces when trying to fetch it to prevent mutations, b=no-bug, c=tabs, workspaces

This commit is contained in:
mr. m
2025-12-23 20:15:00 +01:00
parent 2cc545762e
commit 7753202623
5 changed files with 19 additions and 8 deletions

View File

@@ -1,5 +1,5 @@
diff --git a/browser/themes/shared/tabbrowser/tabs.css b/browser/themes/shared/tabbrowser/tabs.css
index 8a4d3860b344e2dc2128cfc2b1673de582e19c7c..fef63d687ba4e816d3d36f34d4a39adef06359c9 100644
index 8a4d3860b344e2dc2128cfc2b1673de582e19c7c..086171783cd9a8629ccf4b2e90813e58c4793878 100644
--- a/browser/themes/shared/tabbrowser/tabs.css
+++ b/browser/themes/shared/tabbrowser/tabs.css
@@ -21,7 +21,7 @@
@@ -111,7 +111,7 @@ index 8a4d3860b344e2dc2128cfc2b1673de582e19c7c..fef63d687ba4e816d3d36f34d4a39ade
}
-#tabbrowser-arrowscrollbox[orient="vertical"] > #tabbrowser-arrowscrollbox-periphery > #tabs-newtab-button,
+#tabbrowser-arrowscrollbox[orient="vertical"] #tabbrowser-arrowscrollbox-periphery > #tabs-newtab-button,
+#tabs-newtab-button,
#vertical-tabs-newtab-button {
appearance: none;
min-height: var(--tab-min-height);

View File

@@ -312,7 +312,10 @@ class nsZenWindowSync {
if (flags & SYNC_FLAG_ICON) {
aTargetItem.removeAttribute('zen-has-static-icon');
if (gBrowser.isTab(aOriginalItem)) {
gBrowser.setIcon(aTargetItem, gBrowser.getIcon(aOriginalItem));
gBrowser.setIcon(
aTargetItem,
aOriginalItem.getAttribute('image') || gBrowser.getIcon(aOriginalItem)
);
} else if (aOriginalItem.isZenFolder) {
// Icons are a zen-only feature for tab groups.
gZenFolders.setFolderUserIcon(aTargetItem, aOriginalItem.iconURL);

View File

@@ -32,6 +32,7 @@ class ZenPinnedTabsObserver {
);
ChromeUtils.defineESModuleGetters(lazy, {
E10SUtils: 'resource://gre/modules/E10SUtils.sys.mjs',
TabStateCache: 'resource:///modules/sessionstore/TabStateCache.sys.mjs',
});
this.#listenPinnedTabEvents();
}
@@ -486,6 +487,9 @@ class nsZenPinnedTabManager extends nsZenDOMOperatedFeature {
if (icon) {
tab.setAttribute('zen-has-static-icon', 'true');
}
lazy.TabStateCache.update(tab.permanentKey, {
image: null,
});
})
.catch((err) => {
console.error(err);

View File

@@ -824,7 +824,7 @@ class nsZenWorkspaces {
this.#activeWorkspace = this._tempWorkspace?.uuid;
return this._workspaceCache;
}
return this._workspaceCache;
return [...this._workspaceCache];
}
async workspaceBookmarks() {
@@ -1210,7 +1210,7 @@ class nsZenWorkspaces {
}
if (!this.#contextMenuData.workspaceId) {
separator.hidden = false;
for (const workspace of [...this._workspaceCache].reverse()) {
for (const workspace of this.getWorkspaces().reverse()) {
const item = this.generateMenuItemForWorkspace(workspace);
item.addEventListener('command', (e) => {
this.changeWorkspaceWithID(e.target.closest('menuitem').getAttribute('zen-workspace-id'));
@@ -1363,7 +1363,7 @@ class nsZenWorkspaces {
if (this.privateWindowOrDisabled) {
return;
}
const workspaces = this.getWorkspaces();
const workspaces = this._workspaceCache;
const workspace = workspaces.find((w) => w.uuid === id);
if (!workspace) {
console.warn(`Workspace with ID ${id} not found for reordering.`);
@@ -1382,8 +1382,10 @@ class nsZenWorkspaces {
return;
}
workspaces.splice(newPosition, 0, workspace);
// Propagate the changes
this.#propagateWorkspaceData();
// Propagate the changes if the order has changed
if (currentIndex !== newPosition) {
this.#propagateWorkspaceData();
}
}
async openWorkspaceCreation() {

View File

@@ -99,6 +99,8 @@
& toolbarbutton {
margin: 0;
background: transparent;
/* Ignore press state when in overflow, to allow clicks to happen */
scale: 1 !important;
}
/* Inlcude separately since ther'es a bug in the