This commit refactors the ZenSidebarManager and ZenWorkspaces classes. In ZenSidebarManager, the _createWebPanelBrowser method now includes the userContextId when creating a new browser. Additionally, a new method createContainerTabMenu is added to handle the creation of a context menu for container tabs. The contextChangeContainerTab method is also added to handle changing the userContextId for a container tab.
In ZenWorkspaces, the ownerWindow property is now set to the window object. The _contextMenuId property is now bound to the ZenWorkspaces instance. The onclick event handler is modified to use the ownerWindow property and the changeWorkspace method is now called on the ZenWorkspaces instance.
These changes improve the functionality and maintainability of the ZenSidebarManager and ZenWorkspaces classes.
This commit introduces a new preference, `zen.workspaces.force-container-workspace`, which allows users to automatically switch to the workspace associated with a specific tab's container.
This commit modifies the `getContextIdIfNeeded` method to automatically use the active workspace context ID for external calls.
Previously, external calls would use the provided `userContextId` if it was different from the active workspace context ID. Now, if `fromExternal` is true and there's an active workspace, the method will return the active workspace context ID, ensuring consistency with the active workspace.
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 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 prevents multiple registrations of the `ZenWorkspacesEngine`.
Previously, the `ZenWorkspacesEngine` was registered unconditionally every time `ZenWorkspaces` was initialized. This could lead to issues if the engine was already registered.
This commit adds a check to ensure that the engine is only registered if it is not already present. This prevents multiple registrations and ensures that the engine is only initialized once.
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 removes a call to `this.closeWorkspacesSubView()` after saving a workspace.
The previous behavior caused an error to be thrown because main view was already closed.
The previous implementation of the workspace update notification was using `workspaceData.uuid`, which is incorrect. This commit fixes the issue by using `workspace.uuid` instead, ensuring the correct workspace identifier is sent to observers.
This commit adds an observer for the `weave:engine:sync:finish` event and clears the workspace cache when the workspace sync is complete. This ensures that the workspace strip is updated with the latest data after a sync.
This commit adds a new feature to synchronize workspaces to the Services-Sync framework.
- **ZenWorkspacesSync.mjs:** A new file that defines a custom engine for syncing workspaces.
- **ZenWorkspaces.mjs:** Modified to register the ZenWorkspacesEngine with the Service engine manager and to update its state using services-sync's notification system.
This feature enables users to sync their workspaces across devices and seamlessly switch between them using the services-sync mechanism.
This commit addresses a potential crash that could occur when the active workspace no longer exists. The issue was that the code attempted to access the `uuid` property of the first workspace in the list even if the list was empty.
This commit fixes the issue by using optional chaining (`?.`) to safely access the `uuid` property, ensuring the code doesn't crash if the workspace list is empty.
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.