Refactor ZenWorkspaces to use _createNewTabForWorkspace method for preparing new workspace

This commit is contained in:
Mauro Balades
2024-07-13 22:09:50 +02:00
parent 9a816fe73a
commit 7e1c76a1da
9 changed files with 94 additions and 11 deletions

View File

@@ -29,7 +29,20 @@ var ZenWorkspaces = {
return this._workspaceCache;
},
onWorkspacesEnabledChanged() {
if (this.workspaceEnabled) {
this.initializeWorkspaces();
} else {
this._workspaceCache = null;
document.getElementById("zen-workspaces-button")?.remove();
for (let tab of gBrowser.tabs) {
gBrowser.showTab(tab);
}
}
},
async initializeWorkspaces() {
Services.prefs.addObserver("zen.workspaces.enabled", this.onWorkspacesEnabledChanged.bind(this));
this.initializeWorkspacesButton();
let file = new FileUtils.File(this._storeFile);
if (!file.exists()) {
@@ -149,6 +162,10 @@ var ZenWorkspaces = {
initializeWorkspacesButton() {
if (!this.workspaceEnabled) {
return;
} else if (document.getElementById("zen-workspaces-button")) {
let button = document.getElementById("zen-workspaces-button");
button.removeAttribute("hidden");
return;
}
let browserTabs = document.getElementById("tabbrowser-tabs");
let button = document.createElement("toolbarbutton");