(props)
| 270 | } |
| 271 | |
| 272 | export const SettingsKeybinds: Component<{ v2?: boolean }> = (props) => { |
| 273 | const command = useCommand() |
| 274 | const language = useLanguage() |
| 275 | const settings = useSettings() |
| 276 | |
| 277 | const [store, setStore] = createStore({ |
| 278 | active: null as string | null, |
| 279 | filter: "", |
| 280 | }) |
| 281 | |
| 282 | const stop = () => { |
| 283 | if (!store.active) return |
| 284 | setStore("active", null) |
| 285 | command.keybinds(true) |
| 286 | } |
| 287 | |
| 288 | const start = (id: string) => { |
| 289 | if (store.active === id) { |
| 290 | stop() |
| 291 | return |
| 292 | } |
| 293 | |
| 294 | if (store.active) stop() |
| 295 | |
| 296 | setStore("active", id) |
| 297 | command.keybinds(false) |
| 298 | } |
| 299 | |
| 300 | const map = createMemo(() => keybinds(settings.current.keybinds)) |
| 301 | |
| 302 | const hasOverrides = createMemo(() => Object.values(map()).some((x) => typeof x === "string")) |
| 303 | |
| 304 | const resetAll = () => { |
| 305 | stop() |
| 306 | settings.keybinds.resetAll() |
| 307 | showToast({ |
| 308 | title: language.t("settings.shortcuts.reset.toast.title"), |
| 309 | description: language.t("settings.shortcuts.reset.toast.description"), |
| 310 | }) |
| 311 | } |
| 312 | |
| 313 | const list = createMemo(() => { |
| 314 | language.locale() |
| 315 | return listFor(command, map(), language.t("command.palette")) |
| 316 | }) |
| 317 | |
| 318 | const title = (id: string) => list().get(id)?.title ?? "" |
| 319 | |
| 320 | const grouped = createMemo(() => groupedFor(list())) |
| 321 | |
| 322 | const filtered = createMemo(() => { |
| 323 | return filteredFor(store.filter, list(), grouped(), (id) => command.keybind(id) || "") |
| 324 | }) |
| 325 | |
| 326 | const hasResults = createMemo(() => { |
| 327 | for (const group of GROUPS) { |
| 328 | const ids = filtered().get(group) ?? [] |
| 329 | if (ids.length > 0) return true |
nothing calls this directly
no test coverage detected