diff options
| author | Yash <[email protected]> | 2024-04-06 05:03:16 +0000 |
|---|---|---|
| committer | Yash <[email protected]> | 2024-04-06 05:03:16 +0000 |
| commit | 03dd3c093fc2ceef572a710953a6ee810f235ea1 (patch) | |
| tree | 4875cf30ddc1e43bc017cc865f2a6b7be0730e8a /apps/web/src/contexts | |
| parent | remove unused imports (diff) | |
| download | supermemory-03dd3c093fc2ceef572a710953a6ee810f235ea1.tar.xz supermemory-03dd3c093fc2ceef572a710953a6ee810f235ea1.zip | |
add modal
Diffstat (limited to 'apps/web/src/contexts')
| -rw-r--r-- | apps/web/src/contexts/MemoryContext.tsx | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/apps/web/src/contexts/MemoryContext.tsx b/apps/web/src/contexts/MemoryContext.tsx index 6d84f95e..eab1e4fe 100644 --- a/apps/web/src/contexts/MemoryContext.tsx +++ b/apps/web/src/contexts/MemoryContext.tsx @@ -5,10 +5,12 @@ import { CollectedSpaces } from "../../types/memory"; // temperory (will change) export const MemoryContext = React.createContext<{ spaces: CollectedSpaces[]; + deleteSpace: (id: number) => Promise<void>; addSpace: (space: CollectedSpaces) => Promise<void>; }>({ spaces: [], addSpace: async (space) => {}, + deleteSpace: async (id) => {}, }); export const MemoryProvider: React.FC< @@ -22,9 +24,15 @@ export const MemoryProvider: React.FC< }, [spaces], ); + const deleteSpace = useCallback( + async (id: number) => { + setSpaces((prev) => prev.filter((s) => s.id !== id)); + }, + [spaces], + ); return ( - <MemoryContext.Provider value={{ spaces, addSpace }}> + <MemoryContext.Provider value={{ spaces, addSpace, deleteSpace }}> {children} </MemoryContext.Provider> ); |