feat(workspaces): Store workspace theme information

This commit adds the ability to store theme information for workspaces.

- Added `theme_type`, `theme_colors`, `theme_opacity`, `theme_rotation`, and `theme_texture` columns to the `zen_workspaces` table.
- Updated `saveWorkspace` to store the theme information when saving a workspace.
- Removed the unused `zen_workspace_themes` table.

This change allows users to save and restore the theme of their workspaces.
This commit is contained in:
Kristijan Ribarić 2024-10-26 19:13:16 +02:00
parent 4b3e8943f4
commit 182f221373

View file

@ -118,12 +118,14 @@ var ZenWorkspacesStorage = {
// Insert or replace the workspace
await db.executeCached(`
INSERT OR REPLACE INTO zen_workspaces (
uuid, name, icon, is_default, container_id, created_at, updated_at, "position"
uuid, name, icon, is_default, container_id, created_at, updated_at, "position",
theme_type, theme_colors, theme_opacity, theme_rotation, theme_texture
) VALUES (
:uuid, :name, :icon, :is_default, :container_id,
COALESCE((SELECT created_at FROM zen_workspaces WHERE uuid = :uuid), :now),
:now,
:position
:position,
:theme_type, :theme_colors, :theme_opacity, :theme_rotation, :theme_texture
)
`, {
uuid: workspace.uuid,
@ -132,7 +134,12 @@ var ZenWorkspacesStorage = {
is_default: workspace.default ? 1 : 0,
container_id: workspace.containerTabId || null,
now,
position: newPosition
position: newPosition,
theme_type: workspace.theme?.type || null,
theme_colors: workspace.theme ? JSON.stringify(workspace.theme.gradientColors) : null,
theme_opacity: workspace.theme?.opacity || null,
theme_rotation: workspace.theme?.rotation || null,
theme_texture: workspace.theme?.texture || null
});
// Record the change
@ -198,10 +205,6 @@ var ZenWorkspacesStorage = {
timestamp: Math.floor(now / 1000)
});
await db.execute(`
DELETE FROM zen_workspace_themes WHERE uuid = :uuid
`, { uuid });
await this.updateLastChangeTimestamp(db);
});