Commit graph

96 commits

Author SHA1 Message Date
mr. M
2d43df747d
Fixed workspaces not rendering properly 2024-10-14 19:55:01 +02:00
mr. M
6031981acd
Refactor ZenSidebarManager and ZenWorkspaces
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.
2024-10-14 18:31:05 +02:00
mr. M
b645656e6f
Fixed workspaces syncing across windows 2024-10-14 17:45:09 +02:00
Kristijan Ribarić
c9adec30cb Fix: Remove unnecessary then call in ZenWorkspaces and return an array. 2024-10-14 16:21:40 +02:00
Kristijan Ribarić
74bd43f9c9 Add lazy pref getter for zen.workspaces.force-container-workspace 2024-10-14 10:43:14 +02:00
Kristijan Ribarić
b66af853f2 feat(workspaces): Force container tab to open in workspace where it's assigned as default
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.
2024-10-14 10:33:09 +02:00
Kristijan Ribarić
ca0e6030d5 This commit introduces a new parameter allowInheritPrincipal to the getContextIdIfNeeded function in ZenWorkspaces.mjs. This allows recognition of opening bookmarks in new tab so that they can be opened in a default container. 2024-10-13 22:41:37 +02:00
Kristijan Ribarić
893ebcd0f7 fix(workspaces): Use active workspace context ID for external calls
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.
2024-10-13 22:07:30 +02:00
mr. M
600d0d7149
Refactor ZenWorkspaces to handle changing workspaces and update context menu 2024-10-12 21:15:34 +02:00
mr. M
1396523f3b
Refactor ZenWorkspaces to handle changing workspaces and update context menu 2024-10-12 19:08:58 +02:00
mr. M
9a1beadc03
Refactor ZenWorkspaces to handle changing workspaces and update context menu 2024-10-12 17:53:49 +02:00
mauro-balades
c86b344c17
Refactor _expandWorkspacesStrip function to handle undefined browser parameter 2024-10-11 17:52:18 +02:00
Kristijan Ribarić
8ca8157e61 feat: Improve workspace ordering and changes tracking
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.
2024-10-09 19:38:06 +02:00
Kristijan Ribarić
24d7af3da0 Fix: Ensure tab context works after moving a tab to different workspace.
Calling to _workspaces() always gets the fresh data from db, moved caching responsibility to db for getWorkspaces().
2024-10-09 18:14:09 +02:00
mauro 🤙
82e3309310
Update ZenWorkspaces.mjs 2024-10-06 17:08:41 +02:00
Kristijan Ribarić
9abd2d9cc1 feat(workspaces): Migrate workspaces from JSON to the new storage after sync engine has been registered. 2024-10-06 08:35:53 +02:00
mauro-balades
775b5288fb
Fixed workspaces dialog 2024-10-05 23:25:26 +02:00
Kristijan Ribarić
86578cb4d3 feat(workspace): Move observer notifications to workspaces storage 2024-10-05 21:16:07 +02:00
Kristijan Ribarić
863dcfa705 feat(workspaces): remove unused used field from workspaces
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.
2024-10-05 20:16:20 +02:00
Kristijan Ribarić
b28ca11e57 fix(workspaces): Ensure ZenWorkspacesEngine is registered only once
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.
2024-10-05 19:54:08 +02:00
Kristijan Ribarić
0d161326ef feat: Add workspace ordering and changes tracking
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
2024-10-05 19:20:19 +02:00
Kristijan Ribarić
1c7bc5c501 Fix: Remove unnecessary workspace close after saving
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.
2024-10-04 22:40:11 +02:00
Kristijan Ribarić
f1f547fe69 fix(zen-workspaces): Correctly emit workspace update notification
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.
2024-10-04 22:37:35 +02:00
Kristijan Ribarić
4a54adea9a feat(workspaces): Refresh workspace strip after sync completion
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.
2024-10-04 22:37:35 +02:00
Kristijan Ribarić
187dece11c feat: Sync Workspaces to Services-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.
2024-10-04 22:37:35 +02:00
mauro-balades
76d22a1f15
Made the code look cleaner 2024-10-04 18:21:39 +02:00
mauro-balades
1ed9227c01
Added workspaces migration system 2024-10-03 19:38:51 +02:00
Kristijan Ribarić
05acfdb27e Fix: Prevent potential crash when workspace doesn't exist
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.
2024-10-03 11:52:18 +02:00
Kristijan Ribarić
9bcb66c768 feat(workspaces): Use preferences to manage active workspace
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.
2024-10-03 10:19:18 +02:00
Kristijan Ribarić
62be9d1fdd Refactor: Remove unused workspace storage logic 2024-10-02 14:44:48 +02:00
Kristijan Ribarić
de8a857549 feat(workspaces): Store workspaces in a database
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.
2024-10-02 09:37:09 +02:00
mauro-balades
2ea7024eea
Synced workspaces across windows and also implemented MultiWindowFeatures 2024-10-01 23:21:38 +02:00
Sátvik Karanam
65a07ce1c7
use intl segmenter 2024-09-30 02:06:27 -04:00
mauro-balades
cc4f1a3eb2 Fixed workspace cycling with shortcuts 2024-09-29 19:03:26 +02:00
mauro-balades
50afebec5f Fixed workspace cycle using shortcuts 2024-09-29 19:01:54 +02:00
mauro-balades
7af14f1484 Refactor ZenWorkspaces to fix icon mapping issue 2024-09-27 18:56:37 +02:00
mauro-balades
cb24052969 Do not show default container context menu if disabled 2024-09-26 18:58:04 +02:00
mauro-balades
53b7f6eecc Refactor ZenWorkspaces shortcutSwitchTo method to handle out of bounds index gracefully 2024-09-24 16:47:42 +02:00
mauro-balades
58b7b402ac Refactor ZenKeyboardShortcuts to use async/await for initialization and handle potential error when retrieving active workspace from cache 2024-09-23 18:15:17 +02:00
mauro-balades
a97e7e65ed Refactor ZenWorkspaces to use async/await for shortcutSwitchTo method 2024-09-23 17:00:20 +02:00
mauro-balades
6097e99c99 Refactor ZenWorkspaces to use async/await for initialization 2024-09-22 18:30:03 +02:00
mauro-balades
fff6dac398 Refactor ZenWorkspaces to handle potential error when retrieving active workspace from cache 2024-09-22 18:27:56 +02:00
mauro-balades
9a1dcde549 Refactor ZenSidebarManager to handle drag enter event properly 2024-09-22 17:49:16 +02:00
mauro-balades
f56b8c0e59 Refactor ZenViewSplitter to reset tab state when removing a group 2024-09-22 13:36:09 +02:00
mauro-balades
ef5da75e5e Refactor ZenKeyboardShortcuts to add zenChangeWorkspaceBack shortcut 2024-09-21 17:25:09 +02:00
mauro-balades
e14fbd8e5c Refactor ZenCompactMode to add event listeners and flashSidebar enhancements 2024-09-21 16:58:20 +02:00
mauro-balades
3c66cbdc24 Refactor ZenWorkspaces to fix newWorkspacesButton height calculation 2024-09-20 13:33:01 +02:00
mauro-balades
20c2fc640f Refactor ZenWorkspaces to add attributes to newWorkspacesButton 2024-09-20 09:59:55 +02:00
mauro-balades
1d5e336462 Refactor ZenWorkspaces to improve workspace icon strip functionality 2024-09-19 21:05:33 +02:00
mauro-balades
f84a42cb7e Refactor ZenWorkspaces to add event listener for TabBrowserInserted 2024-09-19 07:50:28 +02:00