Remove bindShortcut()
Just statically configure the shortcuts.
Change-Id: I0a1d7b85f74a98c95c591ff2d9a79f02ceea22e5
diff --git a/polygerrit-ui/app/services/shortcuts/shortcuts-service.ts b/polygerrit-ui/app/services/shortcuts/shortcuts-service.ts
index 222ebcf..3cf46bd 100644
--- a/polygerrit-ui/app/services/shortcuts/shortcuts-service.ts
+++ b/polygerrit-ui/app/services/shortcuts/shortcuts-service.ts
@@ -19,14 +19,9 @@
Shortcut,
ShortcutHelpItem,
ShortcutSection,
+ SPECIAL_SHORTCUT,
} from './shortcuts-config';
-/** Enum for all special shortcuts */
-export enum SPECIAL_SHORTCUT {
- DOC_ONLY = 'DOC_ONLY',
- GO_KEY = 'GO_KEY',
- V_KEY = 'V_KEY',
-}
export type SectionView = Array<{binding: string[][]; text: string}>;
/**
@@ -44,26 +39,27 @@
private readonly bindings = new Map<Shortcut, string[]>();
- public _testOnly_getBindings() {
- return this.bindings;
+ private readonly listeners = new Set<ShortcutListener>();
+
+ constructor() {
+ for (const section of config.keys()) {
+ const items = config.get(section) ?? [];
+ for (const item of items) {
+ this.bindings.set(item.shortcut, item.bindings);
+ }
+ }
}
public _testOnly_isEmpty() {
return this.activeHosts.size === 0 && this.listeners.size === 0;
}
- private readonly listeners = new Set<ShortcutListener>();
-
createTitle(shortcutName: Shortcut, section: ShortcutSection) {
const desc = this.getDescription(section, shortcutName);
const shortcut = this.getShortcut(shortcutName);
return desc && shortcut ? `${desc} (shortcut: ${shortcut})` : '';
}
- bindShortcut(shortcut: Shortcut, ...bindings: string[]) {
- this.bindings.set(shortcut, bindings);
- }
-
getBindingsForShortcut(shortcut: Shortcut) {
return this.bindings.get(shortcut);
}