From 9a5efb4a87cb6a50ed36c2c1773a7b7ef9a5ca03 Mon Sep 17 00:00:00 2001 From: mauro-balades Date: Wed, 4 Sep 2024 19:05:09 +0200 Subject: [PATCH] refactor: Simplify workspace initialization logic --- src/ZenWorkspaces.mjs | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/ZenWorkspaces.mjs b/src/ZenWorkspaces.mjs index 7ec0f78..efafb8c 100644 --- a/src/ZenWorkspaces.mjs +++ b/src/ZenWorkspaces.mjs @@ -38,9 +38,9 @@ var ZenWorkspaces = { return this._workspaceCache; }, - onWorkspacesEnabledChanged() { + async onWorkspacesEnabledChanged() { if (this.workspaceEnabled) { - this.initializeWorkspaces(); + throw Error("Shoud've had reloaded the window"); } else { this._workspaceCache = null; document.getElementById("zen-workspaces-button")?.remove(); @@ -50,10 +50,8 @@ var ZenWorkspaces = { } }, - async initializeWorkspaces(init = false) { - if (init) { - Services.prefs.addObserver("zen.workspaces.enabled", this.onWorkspacesEnabledChanged.bind(this)); - } + async initializeWorkspaces() { + Services.prefs.addObserver("zen.workspaces.enabled", this.onWorkspacesEnabledChanged.bind(this)); this.initializeWorkspacesButton(); let file = new FileUtils.File(this._storeFile); if (!file.exists()) { @@ -78,11 +76,9 @@ var ZenWorkspaces = { } this.changeWorkspace(activeWorkspace, true); } - if (init) { - this._initializeWorkspaceCreationIcons(); - this._initializeWorkspaceEditIcons(); - this._initializeWorkspaceTabContextMenus(); - } + this._initializeWorkspaceCreationIcons(); + this._initializeWorkspaceEditIcons(); + this._initializeWorkspaceTabContextMenus(); } },