Refactor ZenKeyboardShortcuts to use async/await for initialization and handle potential error when retrieving active workspace from cache

This commit is contained in:
mauro-balades 2024-09-23 18:15:17 +02:00
parent a97e7e65ed
commit 58b7b402ac
2 changed files with 3 additions and 6 deletions

View file

@ -463,6 +463,7 @@ var gZenKeyboardShortcutsStorage = new class {
var gZenKeyboardShortcutsManager = {
async init() {
if (window.location.href == 'chrome://browser/content/browser.xhtml') {
await SessionStore.promiseInitialized;
console.info('Zen CKS: Initializing shortcuts');
this._currentShortcutList = await this._loadSaved();

View file

@ -365,19 +365,15 @@ var ZenWorkspaces = {
button.removeAttribute('hidden');
return;
}
const nextSibling = document.getElementById('zen-sidepanel-button');
const wrapper = document.createXULElement('toolbarbutton');
wrapper.id = 'zen-workspaces-button';
nextSibling.after(wrapper);
await this._expandWorkspacesStrip();
},
async _expandWorkspacesStrip() {
let workspaces = await this._workspaces();
let workspaceList = document.getElementById('zen-workspaces-button');
const newWorkspacesButton = document.createXULElement(this.shouldShowIconStrip ? 'hbox' : 'toolbarbutton');
const newWorkspacesButton = document.createXULElement('toolbarbutton');
newWorkspacesButton.id = 'zen-workspaces-button';
newWorkspacesButton.setAttribute('removable', 'false');
newWorkspacesButton.setAttribute('removable', 'true');
newWorkspacesButton.setAttribute('showInPrivateBrowsing', 'false');
newWorkspacesButton.setAttribute('tooltiptext', 'Workspaces');