refactor: Initialize shortcuts only on the browser page

This commit is contained in:
Mauro Balades 2024-08-08 20:09:53 +02:00
parent 47c4361082
commit fd893e06f6
2 changed files with 7 additions and 5 deletions

View file

@ -136,7 +136,9 @@ var gZenKeyboardShortcuts = {
}, },
_initShortcuts() { _initShortcuts() {
this._initSavedShortcuts(); if (window.location.href == "chrome://browser/content/browser.xhtml") {
this._initSavedShortcuts();
}
}, },
_createShortcutElement(action) { _createShortcutElement(action) {

View file

@ -71,7 +71,7 @@ var ZenWorkspaces = {
activeWorkspace.used = true; activeWorkspace.used = true;
await this.saveWorkspaces(); await this.saveWorkspaces();
} }
await this.changeWorkspace(activeWorkspace); await this.changeWorkspace(activeWorkspace, true);
} }
this._initializeWorkspaceIcons(); this._initializeWorkspaceIcons();
} }
@ -328,7 +328,7 @@ var ZenWorkspaces = {
button.removeAttribute("disabled"); button.removeAttribute("disabled");
}, },
async changeWorkspace(window) { async changeWorkspace(window, onInit = false) {
if (!this.workspaceEnabled) { if (!this.workspaceEnabled) {
return; return;
} }
@ -348,7 +348,7 @@ var ZenWorkspaces = {
gBrowser.showTab(tab); gBrowser.showTab(tab);
} }
} }
if (typeof firstTab === "undefined") { if (typeof firstTab === "undefined" && !onInit) {
this._createNewTabForWorkspace(window); this._createNewTabForWorkspace(window);
} }
for (let tab of gBrowser.tabs) { for (let tab of gBrowser.tabs) {
@ -389,7 +389,7 @@ var ZenWorkspaces = {
if (!workspaceID) { if (!workspaceID) {
let workspaces = await this._workspaces(); let workspaces = await this._workspaces();
let activeWorkspace = workspaces.workspaces.find(workspace => workspace.used); let activeWorkspace = workspaces.workspaces.find(workspace => workspace.used);
if (!activeWorkspace) { if (!activeWorkspace || tab.hasAttribute("hidden")) {
return; return;
} }
tab.setAttribute("zen-workspace-id", activeWorkspace.uuid); tab.setAttribute("zen-workspace-id", activeWorkspace.uuid);