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-22 22:39:51 +02:00
parent 06bff7da09
commit b4b3c1f0d4

View file

@ -191,7 +191,7 @@ class KeyShortcutModifiers {
} }
return new KeyShortcutModifiers( return new KeyShortcutModifiers(
modifiers['control'] == true, modifiers['ctrl'] == true,
modifiers['alt'] == true, modifiers['alt'] == true,
modifiers['shift'] == true, modifiers['shift'] == true,
modifiers['meta'] == true || modifiers['accel'] == true modifiers['meta'] == true || modifiers['accel'] == true
@ -203,8 +203,6 @@ class KeyShortcutModifiers {
return new KeyShortcutModifiers(false, false, false, false); return new KeyShortcutModifiers(false, false, false, false);
} }
console.log(modifiers);
return new KeyShortcutModifiers( return new KeyShortcutModifiers(
modifiers.includes('control') || modifiers.includes('accel'), modifiers.includes('control') || modifiers.includes('accel'),
modifiers.includes('alt'), modifiers.includes('alt'),
@ -233,7 +231,7 @@ class KeyShortcutModifiers {
toString() { toString() {
let str = ''; let str = '';
if (this.#ctrl) { if (this.#ctrl) {
str += 'control,'; str += 'accel,';
} }
if (this.#alt) { if (this.#alt) {
str += 'alt,'; str += 'alt,';
@ -574,11 +572,11 @@ var gZenKeyboardShortcutsManager = {
await this._saveShortcuts(); await this._saveShortcuts();
}, },
getModifiableShortcuts() { async getModifiableShortcuts() {
let rv = []; let rv = [];
if (!this._currentShortcutList) { if (!this._currentShortcutList) {
this._currentShortcutList = this._loadSaved(); this._currentShortcutList = await this._loadSaved();
} }
for (let shortcut of this._currentShortcutList) { for (let shortcut of this._currentShortcutList) {