This commit adds support for syncing workspace themes across devices.
The following changes were made:
- Added theme properties to the Zen workspace schema:
- `theme_type` (string): Type of theme (e.g., "gradient", "solid").
- `theme_colors` (JSON string): Array of gradient colors.
- `theme_opacity` (number): Opacity of the theme.
- `theme_rotation` (number): Rotation of the theme.
- `theme_texture` (number): Texture of the theme.
- Updated the `ZenWorkspacesSync` class to handle theme data.
- Added validation for theme properties.
- Updated the `ZenWorkspacesStorage` class to save and load workspace themes.
- Bumped the `ZenWorkspacesEngine` version to 2.
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.
The `getWorkspaceTheme()` method has been removed because it is no longer necessary. The theme information is now retrieved directly from the workspace data in `getWorkspaces()`. This change simplifies the code and improves efficiency.
This commit introduces several improvements related to workspace themes:
- **Theme Persistence:** Workspaces now persist their themes in zen_workspaces table alongside other workspace data.
- **Theme Propagation:** The `_propagateWorkspaceData` function now includes an option to clear the workspace cache, preventing stale data from being used when propagating workspace data.
- **Theme Handling:** The `onWorkspaceChange` function now uses the theme from the workspace object or a passed theme, simplifying theme handling.
- **Theme Data Structure:** The `zen_workspaces` table has been updated to store theme data directly, eliminating the need for a separate `zen_workspace_themes` table.
- **Database Schema Changes:** This commit introduces new columns to the `zen_workspaces` table to store theme information, making the database schema more efficient and less redundant.
This commit introduces the ability to reorder workspaces in the workspace manager. This adds functionality to move workspaces up and down within the list, allowing users to customize the order in which they appear.
- Added new buttons for moving workspaces up and down.
- Implemented `moveWorkspaceUp` and `moveWorkspaceDown` methods in `ZenWorkspacesStorage` to handle workspace reordering.
- Updated `ZenWorkspaces` to handle the new reorder mode and button events.
- Modified the workspace list UI to display reorder buttons and indicate when reorder mode is active.
These changes provide users with more control over their workspace organization and improve the overall usability of the workspace manager.
This commit changes the `position` column in the `workspaces` table to be an `INTEGER` instead of a `REAL` data type. This change is made to ensure that workspace positions are always whole numbers, which prevents issues with floating-point precision and ensures consistent ordering of workspaces.
Additionally, it updates the logic for calculating new workspace positions to use `Math.floor` to round down to the nearest integer, ensuring that positions are always integers.
This change also adjusts the `minGap` constant used in the `shouldReorderWorkspaces` function to `1`, which reflects the minimum allowed gap between workspace positions now that they are integers.
This commit introduces improvements to workspace ordering and change tracking in the Zen Workspaces system:
- **Workspace Ordering:**
- Uses `REAL` data type for `position` in `zen_workspaces` table, allowing for more precise and efficient ordering.
- Introduces a new `updateWorkspaceOrder` method to update workspace positions.
- Reorders workspaces with large increments to avoid frequent reordering, ensuring consistent ordering after changes.
- Implements a mechanism to check for necessary reordering after position updates and reorder all workspaces if required.
- **Changes Tracking:**
- Tracks changes to workspaces by inserting a record in `zen_workspaces_changes` for each modified workspace.
- Adds an index on `uuid` column in `zen_workspaces_changes` table for faster querying.
- Updates `getLastChangeTimestamp` method to return the last change timestamp from the changes tracking table, providing accurate timestamp for changes.
These changes optimize workspace management, improve accuracy of ordering, and enhance the performance of change tracking.
This commit improves the notification and handling of workspace changes by:
- **Introducing a dedicated observer notification system:** The `ZenWorkspacesStorage` now uses a private helper method (`_notifyWorkspacesChanged`) to notify observers with a list of changed workspace UUIDs. This provides a more efficient and flexible notification system.
- **Updating `ZenWorkspacesTracker` to parse UUIDs:** The `ZenWorkspacesTracker` now correctly parses the JSON stringified array of UUIDs received from the observer, allowing it to handle multiple workspace changes in a single notification.
- **Refactoring `saveWorkspace`, `removeWorkspace`, `setDefaultWorkspace`, and `updateWorkspaceOrder`:** These methods now consistently collect and notify observers about changed UUIDs.
- **Removing unnecessary code:** The previous approach of notifying observers individually for each change has been removed, leading to code simplification and reduced complexity.
This commit ensures that workspace changes are more reliably and efficiently tracked, leading to a smoother and more responsive workspace management experience.
This commit removes the `used` field from the Workspaces database table and Zen Workspace objects.
The `used` field was originally intended to track whether a workspace was currently being used, but it turned out to be unnecessary. This change simplifies the data model and removes redundant information.
This commit introduces workspace ordering and a new mechanism for tracking changes to workspaces.
**Changes:**
- **Workspace Ordering:** Workspaces can now be ordered using a `position` field. This allows for user-defined ordering of workspaces, improving usability.
- **Changes Tracking:** A new `zen_workspaces_changes` table is added to track changes to workspaces. This allows for more efficient sync operations and improved error handling.
**Benefits:**
- **Improved Workspace Management:** Users can now customize the order of their workspaces.
- **More Efficient Sync:** Changes tracking enables faster and more accurate synchronization of workspaces across devices.
- **Enhanced Error Handling:** Changes tracking helps to identify and resolve conflicts during sync.
**Notes:**
- This change requires deleting the zen_workspaces table in places db
This commit ensures that only one workspace can be marked as default. Previously, multiple workspaces could be marked as default, leading to unexpected behavior.
The commit introduces a transaction to update all workspaces, setting `is_default` to `0` for all workspaces except the one being saved as default. This prevents multiple workspaces from being marked as default.
This commit updates the workspaces system to use preferences to manage the active workspace, instead of storing the active state in each workspace object.
The following changes were made:
- **ZenWorkspaces.mjs:**
- Removed the `used` property from workspace objects and replaced it with a preference (`zen.workspaces.active`) to store the active workspace ID.
- Modified the `getActiveWorkspace` and `changeWorkspace` methods to use preferences instead of the `used` property.
- Added a new `isWorkspaceActive` method to check if a workspace is active.
- **ZenWorkspacesStorage.mjs:**
- Removed the `is_active` column from the `zen_workspaces` table.
- Removed the `setActiveWorkspace` method as the active workspace is now managed by preferences.
This change simplifies the code and makes it easier to manage the active workspace across multiple browser windows and doesn't write to the database on every workspace change. Additionaly, it enables local active workspace selection when workspace sync is implemented.
This commit introduces a new `ZenWorkspacesStorage` class to handle the persistence of workspaces in a database. The previous implementation used JSON files, but this approach brings several advantages, including:
- Improved performance and scalability
- Easier data management and synchronization
- Enhanced security and data integrity
This change removes the reliance on JSON files and streamlines workspace management, leading to a more robust and reliable system.