mirror of
https://github.com/zen-browser/components.git
synced 2025-07-08 16:59:59 +02:00
refactor: Simplify workspace initialization logic
This commit is contained in:
parent
82824a1716
commit
9a5efb4a87
1 changed files with 7 additions and 11 deletions
|
@ -38,9 +38,9 @@ var ZenWorkspaces = {
|
||||||
return this._workspaceCache;
|
return this._workspaceCache;
|
||||||
},
|
},
|
||||||
|
|
||||||
onWorkspacesEnabledChanged() {
|
async onWorkspacesEnabledChanged() {
|
||||||
if (this.workspaceEnabled) {
|
if (this.workspaceEnabled) {
|
||||||
this.initializeWorkspaces();
|
throw Error("Shoud've had reloaded the window");
|
||||||
} else {
|
} else {
|
||||||
this._workspaceCache = null;
|
this._workspaceCache = null;
|
||||||
document.getElementById("zen-workspaces-button")?.remove();
|
document.getElementById("zen-workspaces-button")?.remove();
|
||||||
|
@ -50,10 +50,8 @@ var ZenWorkspaces = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
async initializeWorkspaces(init = false) {
|
async initializeWorkspaces() {
|
||||||
if (init) {
|
|
||||||
Services.prefs.addObserver("zen.workspaces.enabled", this.onWorkspacesEnabledChanged.bind(this));
|
Services.prefs.addObserver("zen.workspaces.enabled", this.onWorkspacesEnabledChanged.bind(this));
|
||||||
}
|
|
||||||
this.initializeWorkspacesButton();
|
this.initializeWorkspacesButton();
|
||||||
let file = new FileUtils.File(this._storeFile);
|
let file = new FileUtils.File(this._storeFile);
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
|
@ -78,12 +76,10 @@ var ZenWorkspaces = {
|
||||||
}
|
}
|
||||||
this.changeWorkspace(activeWorkspace, true);
|
this.changeWorkspace(activeWorkspace, true);
|
||||||
}
|
}
|
||||||
if (init) {
|
|
||||||
this._initializeWorkspaceCreationIcons();
|
this._initializeWorkspaceCreationIcons();
|
||||||
this._initializeWorkspaceEditIcons();
|
this._initializeWorkspaceEditIcons();
|
||||||
this._initializeWorkspaceTabContextMenus();
|
this._initializeWorkspaceTabContextMenus();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
handleTabClose(event) {
|
handleTabClose(event) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue