diff options
| author | Dhravya Shah <[email protected]> | 2025-09-18 20:16:57 -0700 |
|---|---|---|
| committer | Dhravya Shah <[email protected]> | 2025-09-18 20:30:04 -0700 |
| commit | dd3122a4831eac3507b7feb8ba2f1816be5eb3cf (patch) | |
| tree | 4c3eda087974eaaea0b91c85f839eaa8650522e8 /apps/browser-extension/utils/query-hooks.ts | |
| parent | newish get started page (diff) | |
| download | supermemory-09-18-format_browser_extension.tar.xz supermemory-09-18-format_browser_extension.zip | |
format browser extension09-18-format_browser_extension
Diffstat (limited to 'apps/browser-extension/utils/query-hooks.ts')
| -rw-r--r-- | apps/browser-extension/utils/query-hooks.ts | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/apps/browser-extension/utils/query-hooks.ts b/apps/browser-extension/utils/query-hooks.ts index 721a68ad..f1b683e7 100644 --- a/apps/browser-extension/utils/query-hooks.ts +++ b/apps/browser-extension/utils/query-hooks.ts @@ -1,21 +1,21 @@ /** * React Query hooks for supermemory API */ -import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query" +import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"; import { fetchProjects, getDefaultProject, saveMemory, searchMemories, setDefaultProject, -} from "./api" -import type { MemoryPayload } from "./types" +} from "./api"; +import type { MemoryPayload } from "./types"; // Query Keys export const queryKeys = { projects: ["projects"] as const, defaultProject: ["defaultProject"] as const, -} +}; // Projects Query export function useProjects(options?: { enabled?: boolean }) { @@ -24,7 +24,7 @@ export function useProjects(options?: { enabled?: boolean }) { queryFn: fetchProjects, staleTime: 5 * 60 * 1000, // 5 minutes enabled: options?.enabled ?? true, - }) + }); } // Default Project Query @@ -34,31 +34,31 @@ export function useDefaultProject(options?: { enabled?: boolean }) { queryFn: getDefaultProject, staleTime: 2 * 60 * 1000, // 2 minutes enabled: options?.enabled ?? true, - }) + }); } // Set Default Project Mutation export function useSetDefaultProject() { - const queryClient = useQueryClient() + const queryClient = useQueryClient(); return useMutation({ mutationFn: setDefaultProject, onSuccess: (_, project) => { - queryClient.setQueryData(queryKeys.defaultProject, project) + queryClient.setQueryData(queryKeys.defaultProject, project); }, - }) + }); } // Save Memory Mutation export function useSaveMemory() { return useMutation({ mutationFn: (payload: MemoryPayload) => saveMemory(payload), - }) + }); } // Search Memories Mutation export function useSearchMemories() { return useMutation({ mutationFn: (query: string) => searchMemories(query), - }) + }); } |