From 182f221373d207c8bbd5632b7597dc18a91b30d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristijan=20Ribari=C4=87?= Date: Sat, 26 Oct 2024 19:13:16 +0200 Subject: [PATCH] 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. --- src/ZenWorkspacesStorage.mjs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/ZenWorkspacesStorage.mjs b/src/ZenWorkspacesStorage.mjs index f43c742..d80c694 100644 --- a/src/ZenWorkspacesStorage.mjs +++ b/src/ZenWorkspacesStorage.mjs @@ -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); });