diff --git a/src/zen/sessionstore/ZenSessionManager.sys.mjs b/src/zen/sessionstore/ZenSessionManager.sys.mjs index 724087d98..176d4a102 100644 --- a/src/zen/sessionstore/ZenSessionManager.sys.mjs +++ b/src/zen/sessionstore/ZenSessionManager.sys.mjs @@ -142,7 +142,11 @@ export class nsZenSessionManager { // gotten the opportunity to save the session yet. if (!Services.prefs.getBoolPref(MIGRATION_PREF, false)) { Services.prefs.setBoolPref(MIGRATION_PREF, true); - for (const winData of initialState.windows || []) { + this.#sidebar = { + ...this.#sidebar, + spaces: this._migrationSpaceData || [], + }; + for (const winData of initialState?.windows || []) { winData.spaces = this._migrationSpaceData || []; } delete this._migrationSpaceData; diff --git a/src/zen/workspaces/ZenWorkspaces.mjs b/src/zen/workspaces/ZenWorkspaces.mjs index 9b3941cc9..92eea4991 100644 --- a/src/zen/workspaces/ZenWorkspaces.mjs +++ b/src/zen/workspaces/ZenWorkspaces.mjs @@ -850,10 +850,10 @@ class nsZenWorkspaces { return this._workspaceCache; } - async restoreWorkspacesFromSessionStore(aWinData) { - this._workspaceCache = aWinData.spaces || [ - await this.createAndSaveWorkspace('Space', undefined, true), - ]; + async restoreWorkspacesFromSessionStore(aWinData = {}) { + this._workspaceCache = aWinData.spaces?.length + ? aWinData.spaces + : [await this.createAndSaveWorkspace('Space', undefined, true)]; this.activeWorkspace = aWinData.activeZenSpace || this._workspaceCache[0].uuid; await this.initializeWorkspaces(); this.#hasInitialized = true; diff --git a/src/zen/workspaces/ZenWorkspacesStorage.mjs b/src/zen/workspaces/ZenWorkspacesStorage.mjs index 63097e240..80c7a82e5 100644 --- a/src/zen/workspaces/ZenWorkspacesStorage.mjs +++ b/src/zen/workspaces/ZenWorkspacesStorage.mjs @@ -26,8 +26,7 @@ window.ZenWorkspaceBookmarksStorage = { workspace_uuid TEXT NOT NULL, created_at INTEGER NOT NULL, updated_at INTEGER NOT NULL, - UNIQUE(bookmark_guid, workspace_uuid), - FOREIGN KEY(workspace_uuid) REFERENCES zen_workspaces(uuid) ON DELETE CASCADE, + UNIQUE(bookmark_guid), FOREIGN KEY(bookmark_guid) REFERENCES moz_bookmarks(guid) ON DELETE CASCADE ) `); @@ -46,8 +45,7 @@ window.ZenWorkspaceBookmarksStorage = { workspace_uuid TEXT NOT NULL, change_type TEXT NOT NULL, timestamp INTEGER NOT NULL, - UNIQUE(bookmark_guid, workspace_uuid), - FOREIGN KEY(workspace_uuid) REFERENCES zen_workspaces(uuid) ON DELETE CASCADE, + UNIQUE(bookmark_guid), FOREIGN KEY(bookmark_guid) REFERENCES moz_bookmarks(guid) ON DELETE CASCADE ) `);