mirror of
https://github.com/zen-browser/components.git
synced 2025-07-10 02:15:30 +02:00
Refactor ZenWorkspaces to fix newWorkspacesButton height calculation
This commit is contained in:
parent
20c2fc640f
commit
3c66cbdc24
2 changed files with 16 additions and 3 deletions
|
@ -77,11 +77,11 @@ var ZenWorkspaces = {
|
|||
async initializeWorkspaces() {
|
||||
Services.prefs.addObserver('zen.workspaces.enabled', this.onWorkspacesEnabledChanged.bind(this));
|
||||
Services.prefs.addObserver('zen.workspaces.show-icon-strip', this.onWorkspacesIconStripChanged.bind(this));
|
||||
await this.initializeWorkspacesButton();
|
||||
let file = new FileUtils.File(this._storeFile);
|
||||
if (!file.exists()) {
|
||||
await IOUtils.writeJSON(this._storeFile, {});
|
||||
}
|
||||
await this.initializeWorkspacesButton();
|
||||
if (this.workspaceEnabled) {
|
||||
this._initializeWorkspaceCreationIcons();
|
||||
this._initializeWorkspaceEditIcons();
|
||||
|
@ -391,7 +391,11 @@ var ZenWorkspaces = {
|
|||
if (workspace.default) {
|
||||
button.setAttribute('default', 'true');
|
||||
}
|
||||
button.onclick = (async () => {
|
||||
button.onclick = (async (_, event) => {
|
||||
// Make sure it's not a context menu event
|
||||
if (event.button !== 0) {
|
||||
return;
|
||||
}
|
||||
await this.changeWorkspace(workspace);
|
||||
}).bind(this, workspace);
|
||||
let icon = document.createXULElement('div');
|
||||
|
@ -400,6 +404,11 @@ var ZenWorkspaces = {
|
|||
button.appendChild(icon);
|
||||
newWorkspacesButton.appendChild(button);
|
||||
}
|
||||
// Listen for context menu events and open the all workspaces dialog
|
||||
newWorkspacesButton.addEventListener('contextmenu', (event) => {
|
||||
event.preventDefault();
|
||||
this.openWorkspacesDialog(event);
|
||||
});
|
||||
}
|
||||
|
||||
workspaceList.after(newWorkspacesButton);
|
||||
|
@ -568,6 +577,10 @@ var ZenWorkspaces = {
|
|||
let firstTab = undefined;
|
||||
let workspaces = await this._workspaces();
|
||||
for (let workspace of workspaces.workspaces) {
|
||||
if (workspace.uuid === window.uuid && workspace.used) {
|
||||
// If the workspace is already active, do nothing
|
||||
return;
|
||||
}
|
||||
workspace.used = workspace.uuid === window.uuid;
|
||||
}
|
||||
await this.unsafeSaveWorkspaces(workspaces);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue