feat: Take into consideration win data may not have allocated spaces, b=no-bug, c=workspaces

This commit is contained in:
mr. m
2025-12-17 00:54:36 +01:00
parent 7ddace35f9
commit 16d31a1045
3 changed files with 11 additions and 9 deletions

View File

@@ -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;

View File

@@ -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;

View File

@@ -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
)
`);