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() {
this._initSavedShortcuts();
if (window.location.href == "chrome://browser/content/browser.xhtml") {
this._initSavedShortcuts();
}
},
_createShortcutElement(action) {

View file

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