mirror of
https://github.com/zen-browser/components.git
synced 2025-07-08 16:30:01 +02:00
Refactor ZenWorkspaces initialization and workspace check
This commit is contained in:
parent
5f61c3b5af
commit
0f775df5e6
1 changed files with 14 additions and 9 deletions
|
@ -5,13 +5,8 @@ var ZenWorkspaces = {
|
||||||
*/
|
*/
|
||||||
_lastSelectedWorkspaceTabs: {},
|
_lastSelectedWorkspaceTabs: {},
|
||||||
|
|
||||||
async init() {
|
init() {
|
||||||
let docElement = document.documentElement;
|
if (!this.shouldHaveWorkspaces) {
|
||||||
if (
|
|
||||||
docElement.getAttribute('chromehidden').includes('toolbar') ||
|
|
||||||
docElement.getAttribute('chromehidden').includes('menubar') ||
|
|
||||||
docElement.hasAttribute('privatebrowsingmode')
|
|
||||||
) {
|
|
||||||
console.warn('ZenWorkspaces: !!! ZenWorkspaces is disabled in hidden windows !!!');
|
console.warn('ZenWorkspaces: !!! ZenWorkspaces is disabled in hidden windows !!!');
|
||||||
return; // We are in a hidden window, don't initialize ZenWorkspaces
|
return; // We are in a hidden window, don't initialize ZenWorkspaces
|
||||||
}
|
}
|
||||||
|
@ -22,8 +17,19 @@ var ZenWorkspaces = {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
get shouldHaveWorkspaces() {
|
||||||
|
delete this.shouldHaveWorkspaces;
|
||||||
|
let docElement = document.documentElement;
|
||||||
|
this.shouldHaveWorkspaces = !(docElement.hasAttribute('privatebrowsingmode')
|
||||||
|
|| docElement.getAttribute('chromehidden').includes('toolbar')
|
||||||
|
|| docElement.getAttribute('chromehidden').includes('menubar'));
|
||||||
|
return this.shouldHaveWorkspaces;
|
||||||
|
},
|
||||||
|
|
||||||
get workspaceEnabled() {
|
get workspaceEnabled() {
|
||||||
return Services.prefs.getBoolPref('zen.workspaces.enabled', false);
|
delete this.workspaceEnabled;
|
||||||
|
this.workspaceEnabled = Services.prefs.getBoolPref('zen.workspaces.enabled', false) && this.shouldHaveWorkspaces;
|
||||||
|
return this.workspaceEnabled;
|
||||||
},
|
},
|
||||||
|
|
||||||
getActiveWorkspaceFromCache() {
|
getActiveWorkspaceFromCache() {
|
||||||
|
@ -744,4 +750,3 @@ var ZenWorkspaces = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
ZenWorkspaces.init();
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue