From ddf84fa3df832f0036e7bc51cc9613c363f1a9ab Mon Sep 17 00:00:00 2001 From: mauro-balades Date: Mon, 2 Sep 2024 14:38:59 +0200 Subject: [PATCH] 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 --- src/ZenWorkspaces.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ZenWorkspaces.mjs b/src/ZenWorkspaces.mjs index 7327c1e..4f71529 100644 --- a/src/ZenWorkspaces.mjs +++ b/src/ZenWorkspaces.mjs @@ -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(); }