From 4a54adea9a2c23d1c1cdb91ec7b1895ecbc57766 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristijan=20Ribari=C4=87?= Date: Fri, 4 Oct 2024 14:04:24 +0200 Subject: [PATCH] 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. --- src/ZenWorkspaces.mjs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/ZenWorkspaces.mjs b/src/ZenWorkspaces.mjs index 382643e..fbb0c1b 100644 --- a/src/ZenWorkspaces.mjs +++ b/src/ZenWorkspaces.mjs @@ -22,6 +22,20 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature { Weave.Service.engineManager.register(ZenWorkspacesEngine); await this.initializeWorkspaces(); console.info('ZenWorkspaces: ZenWorkspaces initialized'); + + // Add observer for sync completion + Services.obs.addObserver(this, "weave:engine:sync:finish"); + } + + observe(subject, topic, data) { + if (topic === "weave:engine:sync:finish" && data === "workspaces") { + this._workspaceCache = null; // Clear cache to fetch fresh data + this.updateWorkspaceStrip(); + } + } + + updateWorkspaceStrip() { + this._propagateWorkspaceData().catch(console.error); } get shouldHaveWorkspaces() {