refactor: Improve workspace initialization logic

Simplify the logic for initializing workspaces in the ZenWorkspaces module. The code now checks for the last used workspace and sets it as the active workspace if available. If the last used workspace is not found, it creates a default workspace or selects the first available workspace. This change improves the user experience by automatically loading the last used workspace or providing a default option when no workspaces exist.

Closes #376
This commit is contained in:
mauro-balades 2024-09-02 14:38:59 +02:00
parent e7e70f7ced
commit ddf84fa3df

View file

@ -63,9 +63,9 @@ var ZenWorkspaces = {
if (workspaces.workspaces.length === 0) {
await this.createAndSaveWorkspace("Default Workspace", true);
} else {
let activeWorkspace = workspaces.workspaces.find(workspace => workspace.default);
let activeWorkspace = workspaces.workspaces.find(workspace => workspace.used);
if (!activeWorkspace) {
activeWorkspace = workspaces.workspaces.find(workspace => workspace.used);
activeWorkspace = workspaces.workspaces.find(workspace => workspace.default);
activeWorkspace.used = true;
await this.saveWorkspaces();
}