fix: Fixed session restore for folders with invalid workspace IDs, b=no-bug, c=folders, workspaces

This commit is contained in:
Mr. M
2025-08-20 20:57:51 +02:00
parent d2e0a38bf3
commit 4a87be372d
2 changed files with 11 additions and 9 deletions

View File

@@ -637,7 +637,7 @@
_forZenEmptyTab: true,
});
tabs = [...tabs, emptyTab];
tabs = [emptyTab, ...tabs];
const folder = this._createFolderNode(options);
if (options.initialPinId) {
@@ -1249,7 +1249,7 @@
if (prevSibling) {
if (gBrowser.isTabGroup(prevSibling)) {
prevSiblingInfo = { type: 'group', id: prevSibling.id };
} else if (gBrowser.isTab(prevSibling)) {
} else if (gBrowser.isTab(prevSibling) && prevSibling.hasAttribute('zen-pin-id')) {
const zenPinId = prevSibling.getAttribute('zen-pin-id');
prevSiblingInfo = { type: 'tab', id: zenPinId };
} else {
@@ -1318,7 +1318,9 @@
workingData.node = oldGroup;
}
while (oldGroup.tabs.length > 0) {
workingData.containingTabsFragment.appendChild(oldGroup.tabs[0]);
const tab = oldGroup.tabs[0];
tab.setAttribute('zen-workspace-id', folderData.workspaceId);
workingData.containingTabsFragment.appendChild(tab);
}
if (!folderData.splitViewGroup) {
oldGroup.remove();

View File

@@ -494,7 +494,7 @@ var gZenWorkspaces = new (class extends nsZenMultiWindowFeature {
workspaceWrapper.addEventListener(
'ZenWorkspaceAttached',
() => {
this._organizeTabsToWorkspaceSections(
this.#organizeTabsToWorkspaceSections(
workspace,
workspaceWrapper.tabsContainer,
workspaceWrapper.pinnedTabsContainer,
@@ -508,7 +508,7 @@ var gZenWorkspaces = new (class extends nsZenMultiWindowFeature {
});
}
_organizeTabsToWorkspaceSections(workspace, section, pinnedSection, tabs) {
#organizeTabsToWorkspaceSections(workspace, section, pinnedSection, tabs) {
const workspaceTabs = Array.from(tabs).filter(
(tab) => tab.getAttribute('zen-workspace-id') === workspace.uuid
);
@@ -545,11 +545,11 @@ var gZenWorkspaces = new (class extends nsZenMultiWindowFeature {
}
initializeWorkspaceNavigation() {
this._setupAppCommandHandlers();
this._setupSidebarHandlers();
this.#setupAppCommandHandlers();
this.#setupSidebarHandlers();
}
_setupAppCommandHandlers() {
#setupAppCommandHandlers() {
// Remove existing handler temporarily - this is needed so that _handleAppCommand is called before the original
window.removeEventListener('AppCommand', HandleAppCommandEvent, true);
@@ -591,7 +591,7 @@ var gZenWorkspaces = new (class extends nsZenMultiWindowFeature {
});
}
_setupSidebarHandlers() {
#setupSidebarHandlers() {
const toolbox = gNavToolbox;
const scrollCooldown = 200; // Milliseconds to wait before allowing another scroll