Refactor ZenStartup.mjs and zen-settings.js

- Refactor ZenStartup.mjs to use gZenKeyboardShortcutsManager instead of gZenKeyboardShortcuts.
- Refactor zen-settings.js to use async/await for _resetCKS and _handleKeyDown functions.
This commit is contained in:
mauro-balades
2024-09-22 22:13:46 +02:00
parent e03d6dd3fd
commit 818ebd1d85
3 changed files with 8 additions and 8 deletions

View File

@@ -45,7 +45,7 @@
gZenUIManager.init();
gZenVerticalTabsManager.init();
gZenCompactModeManager.init();
gZenKeyboardShortcuts.init();
gZenKeyboardShortcutsManager.init();
function throttle(f, delay) {
let timer = 0;

View File

@@ -714,18 +714,18 @@ var gZenCKSSettings = {
}
},
_resetCKS(input, key) {
async _resetCKS(input, key) {
input.value = 'Not set';
input.classList.add('zenCKSOption-input-not-set');
input.classList.remove('zenCKSOption-input-invalid');
gZenKeyboardShortcuts.setShortcut(key, null);
await gZenKeyboardShortcuts.setShortcut(key, null);
},
_initializeEvents() {
window.addEventListener('keydown', this._handleKeyDown.bind(this));
},
_handleKeyDown(event) {
async _handleKeyDown(event) {
if (!this._currentAction) {
return;
}
@@ -747,12 +747,12 @@ var gZenCKSSettings = {
input.blur();
return;
} else if (event.key === 'Backspace' && shortcutWithoutModifiers) {
this._resetCKS(input, this._currentAction);
await this._resetCKS(input, this._currentAction);
return;
}
if (!shortcut.ctrl && !shortcut.alt && !shortcut.shift && !shortcut.meta) {
this._resetCKS(input, this._currentAction);
await this._resetCKS(input, this._currentAction);
return; // No modifiers, ignore.
}
@@ -765,7 +765,7 @@ var gZenCKSSettings = {
}
event.preventDefault();
gZenKeyboardShortcuts.setShortcut(this._currentAction, shortcut);
await gZenKeyboardShortcuts.setShortcut(this._currentAction, shortcut);
input.value = gZenKeyboardShortcuts.shortCutToString(shortcut);
input.classList.remove('zenCKSOption-input-not-set');