Open History to see the last commit
1import { create } from "zustand";
2
3interface CommandPaletteOpenIntent {
4 kind: "add-project";
5 requestId: number;
6}
7
8interface CommandPaletteStore {
9 open: boolean;
10 openIntent: CommandPaletteOpenIntent | null;
11 setOpen: (open: boolean) => void;
12 toggleOpen: () => void;
13 openAddProject: () => void;
14 clearOpenIntent: () => void;
15}
16
17export const useCommandPaletteStore = create<CommandPaletteStore>((set) => ({
18 open: false,
19 openIntent: null,
20 setOpen: (open) => set({ open, ...(open ? {} : { openIntent: null }) }),
21 toggleOpen: () =>
22 set((state) => ({ open: !state.open, ...(state.open ? { openIntent: null } : {}) })),
23 openAddProject: () =>
24 set((state) => ({
25 open: true,
26 openIntent: {
27 kind: "add-project",
28 requestId: (state.openIntent?.requestId ?? 0) + 1,
29 },
30 })),
31 clearOpenIntent: () => set({ openIntent: null }),
32}));