/
index.tsx
52 lines (46 loc) · 1.44 KB
/
index.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import { ActionPanel, List, Action, useNavigation } from "@raycast/api";
import { usePromise } from "@raycast/utils";
import { StoreCommand } from "../Store";
import { loadCommands } from "./loadCommands";
import { evalCommandModule } from "./utils";
export const CommandList = () => {
const { isLoading, data: commands = [], mutate } = usePromise(loadCommands);
const { push } = useNavigation();
return (
<List isLoading={isLoading} searchBarPlaceholder="Search for apps and commands...">
{commands.map((command, index) => {
return (
<List.Item
key={`${command.title}-${index}`}
title={command.title}
subtitle={command.subtitle}
actions={
<ActionPanel>
<Action
title="Open Command"
onAction={() => {
try {
const Comp = evalCommandModule(command.requirePath);
push(<Comp />);
} catch (error) {
console.error(error);
}
}}
/>
</ActionPanel>
}
/>
);
})}
<List.Item
key="store"
title="Store"
actions={
<ActionPanel>
<Action.Push title="Open Store" target={<StoreCommand refresh={mutate} />} />
</ActionPanel>
}
/>
</List>
);
};