From 893ebcd0f714e5dea4ac106223558ad6ed7591ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristijan=20Ribari=C4=87?= Date: Sun, 13 Oct 2024 22:07:30 +0200 Subject: [PATCH] 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. --- src/ZenWorkspaces.mjs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/ZenWorkspaces.mjs b/src/ZenWorkspaces.mjs index 58fe842..38ab97d 100644 --- a/src/ZenWorkspaces.mjs +++ b/src/ZenWorkspaces.mjs @@ -874,10 +874,19 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature { }); } - getContextIdIfNeeded(userContextId) { + getContextIdIfNeeded(userContextId, fromExternal) { + if(!this.workspaceEnabled) { + return [userContextId, false]; + } + const activeWorkspace = this.getActiveWorkspaceFromCache(); const activeWorkspaceUserContextId = activeWorkspace?.containerTabId; - if ((typeof userContextId !== 'undefined' && userContextId !== activeWorkspaceUserContextId) || !this.workspaceEnabled) { + + if(fromExternal && !!activeWorkspaceUserContextId) { + return [activeWorkspaceUserContextId, true]; + } + + if (typeof userContextId !== 'undefined' && userContextId !== activeWorkspaceUserContextId) { return [userContextId, false]; } return [activeWorkspaceUserContextId, true];