| 1 | import { createSelector } from "@reduxjs/toolkit"; |
| 2 | import { |
| 3 | ComboBoxItem, |
| 4 | ComboBoxItemType, |
| 5 | } from "../../components/mainInput/types"; |
| 6 | import { RootState } from "../store"; |
| 7 | |
| 8 | export const selectSlashCommandComboBoxInputs = createSelector( |
| 9 | [(state: RootState) => state.config.config.slashCommands], |
| 10 | (slashCommands) => { |
| 11 | return ( |
| 12 | slashCommands?.map((cmd) => { |
| 13 | return { |
| 14 | title: cmd.name, |
| 15 | description: cmd.description, |
| 16 | type: "slashCommand" as ComboBoxItemType, |
| 17 | content: cmd.prompt, |
| 18 | } as ComboBoxItem; |
| 19 | }) || [] |
| 20 | ); |
| 21 | }, |
| 22 | ); |
| 23 | |
| 24 | export const selectSlashCommands = createSelector( |
| 25 | [(state: RootState) => state.config.config.slashCommands], |
| 26 | (slashCommands) => { |
| 27 | return slashCommands || []; |
| 28 | }, |
| 29 | ); |
| 30 | |
| 31 | export const selectSubmenuContextProviders = createSelector( |
| 32 | [(state: RootState) => state.config.config.contextProviders], |
| 33 | (providers) => { |
| 34 | return providers?.filter((desc) => desc.type === "submenu") || []; |
| 35 | }, |
| 36 | ); |
| 37 | |
| 38 | export const selectDefaultContextProviders = createSelector( |
| 39 | [(state: RootState) => state.config.config.experimental?.defaultContext], |
| 40 | (defaultProviders) => { |
| 41 | return defaultProviders ?? []; |
| 42 | }, |
| 43 | ); |
| 44 | |
| 45 | export const selectUseActiveFile = createSelector( |
| 46 | [(state: RootState) => state.config.config.experimental?.defaultContext], |
| 47 | (defaultContext) => defaultContext?.includes("activeFile" as any), |
| 48 | ); |