mirror of
https://github.com/zen-browser/components.git
synced 2025-07-07 22:19:58 +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;
|
||||
},
|
||||
|
||||
onWorkspacesEnabledChanged() {
|
||||
async onWorkspacesEnabledChanged() {
|
||||
if (this.workspaceEnabled) {
|
||||
this.initializeWorkspaces();
|
||||
throw Error("Shoud've had reloaded the window");
|
||||
} else {
|
||||
this._workspaceCache = null;
|
||||
document.getElementById("zen-workspaces-button")?.remove();
|
||||
|
@ -50,10 +50,8 @@ var ZenWorkspaces = {
|
|||
}
|
||||
},
|
||||
|
||||
async initializeWorkspaces(init = false) {
|
||||
if (init) {
|
||||
Services.prefs.addObserver("zen.workspaces.enabled", this.onWorkspacesEnabledChanged.bind(this));
|
||||
}
|
||||
async initializeWorkspaces() {
|
||||
Services.prefs.addObserver("zen.workspaces.enabled", this.onWorkspacesEnabledChanged.bind(this));
|
||||
this.initializeWorkspacesButton();
|
||||
let file = new FileUtils.File(this._storeFile);
|
||||
if (!file.exists()) {
|
||||
|
@ -78,11 +76,9 @@ var ZenWorkspaces = {
|
|||
}
|
||||
this.changeWorkspace(activeWorkspace, true);
|
||||
}
|
||||
if (init) {
|
||||
this._initializeWorkspaceCreationIcons();
|
||||
this._initializeWorkspaceEditIcons();
|
||||
this._initializeWorkspaceTabContextMenus();
|
||||
}
|
||||
this._initializeWorkspaceCreationIcons();
|
||||
this._initializeWorkspaceEditIcons();
|
||||
this._initializeWorkspaceTabContextMenus();
|
||||
}
|
||||
},
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue