()
| 66 | ] |
| 67 | |
| 68 | function App() { |
| 69 | const [shortcuts, setShortcuts] = |
| 70 | createSignal<Array<Shortcut>>(INITIAL_SHORTCUTS) |
| 71 | |
| 72 | // Track which shortcut is being edited (recording + name/description editing) |
| 73 | const [editingId, setEditingId] = createSignal<string | null>(null) |
| 74 | // Draft name/description while editing |
| 75 | const [draftName, setDraftName] = createSignal('') |
| 76 | const [draftDescription, setDraftDescription] = createSignal('') |
| 77 | |
| 78 | const recorder = createHotkeyRecorder({ |
| 79 | onRecord: (hotkey: Hotkey) => { |
| 80 | const id = editingId() |
| 81 | if (id) { |
| 82 | setShortcuts((prev) => |
| 83 | prev.map((s) => |
| 84 | s.id === id |
| 85 | ? { |
| 86 | ...s, |
| 87 | hotkey, |
| 88 | name: draftName(), |
| 89 | description: draftDescription(), |
| 90 | } |
| 91 | : s, |
| 92 | ), |
| 93 | ) |
| 94 | setEditingId(null) |
| 95 | } |
| 96 | }, |
| 97 | onCancel: () => { |
| 98 | const id = editingId() |
| 99 | if (id) { |
| 100 | setShortcuts((prev) => { |
| 101 | const shortcut = prev.find((s) => s.id === id) |
| 102 | if (shortcut && shortcut.hotkey === '') { |
| 103 | return prev.filter((s) => s.id !== id) |
| 104 | } |
| 105 | return prev |
| 106 | }) |
| 107 | } |
| 108 | setEditingId(null) |
| 109 | }, |
| 110 | onClear: () => { |
| 111 | const id = editingId() |
| 112 | if (id) { |
| 113 | setShortcuts((prev) => |
| 114 | prev.map((s) => |
| 115 | s.id === id |
| 116 | ? { |
| 117 | ...s, |
| 118 | hotkey: '' as Hotkey | '', |
| 119 | name: draftName(), |
| 120 | description: draftDescription(), |
| 121 | } |
| 122 | : s, |
| 123 | ), |
| 124 | ) |
| 125 | setEditingId(null) |
nothing calls this directly
no test coverage detected