Add lazy pref getter for zen.workspaces.force-container-workspace

This commit is contained in:
Kristijan Ribarić 2024-10-14 10:43:14 +02:00
parent b66af853f2
commit 74bd43f9c9

View file

@ -18,6 +18,12 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
true, true,
this._expandWorkspacesStrip.bind(this) this._expandWorkspacesStrip.bind(this)
); );
XPCOMUtils.defineLazyPreferenceGetter(
this,
'shouldForceContainerTabsToWorkspace',
'zen.workspaces.force-container-workspace',
true
);
ChromeUtils.defineLazyGetter(this, 'tabContainer', () => document.getElementById('tabbrowser-tabs')); ChromeUtils.defineLazyGetter(this, 'tabContainer', () => document.getElementById('tabbrowser-tabs'));
await ZenWorkspacesStorage.init(); await ZenWorkspacesStorage.init();
if(!Weave.Service.engineManager.get("workspaces")) { if(!Weave.Service.engineManager.get("workspaces")) {
@ -879,7 +885,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
return [userContextId, false]; return [userContextId, false];
} }
if(Services.prefs.getBoolPref('zen.workspaces.force-container-workspace', false) && typeof userContextId !== 'undefined' && this._workspaceCache?.workspaces) { if(this.shouldForceContainerTabsToWorkspace && typeof userContextId !== 'undefined' && this._workspaceCache?.workspaces) {
const workspace = this._workspaceCache.workspaces.find((workspace) => workspace.containerTabId === userContextId); const workspace = this._workspaceCache.workspaces.find((workspace) => workspace.containerTabId === userContextId);
if(workspace && workspace.uuid !== this.getActiveWorkspaceFromCache().uuid) { if(workspace && workspace.uuid !== this.getActiveWorkspaceFromCache().uuid) {
this.changeWorkspace(workspace).then(() => { this.changeWorkspace(workspace).then(() => {