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 1/2] 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]; From ca0e6030d55199cfe940f9f02a0aaa87d4fa5b52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristijan=20Ribari=C4=87?= Date: Sun, 13 Oct 2024 22:41:37 +0200 Subject: [PATCH 2/2] This commit introduces a new parameter `allowInheritPrincipal` to the `getContextIdIfNeeded` function in `ZenWorkspaces.mjs`. This allows recognition of opening bookmarks in new tab so that they can be opened in a default container. --- src/ZenWorkspaces.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ZenWorkspaces.mjs b/src/ZenWorkspaces.mjs index 38ab97d..3989481 100644 --- a/src/ZenWorkspaces.mjs +++ b/src/ZenWorkspaces.mjs @@ -874,7 +874,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature { }); } - getContextIdIfNeeded(userContextId, fromExternal) { + getContextIdIfNeeded(userContextId, fromExternal, allowInheritPrincipal) { if(!this.workspaceEnabled) { return [userContextId, false]; } @@ -882,7 +882,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature { const activeWorkspace = this.getActiveWorkspaceFromCache(); const activeWorkspaceUserContextId = activeWorkspace?.containerTabId; - if(fromExternal && !!activeWorkspaceUserContextId) { + if((fromExternal || allowInheritPrincipal === false) && !!activeWorkspaceUserContextId) { return [activeWorkspaceUserContextId, true]; }