mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-26 17:26:23 +02:00
- Pass is_public from request body in create_prompt route - Only bump version on content field changes (name, prompt, mode), not on is_public toggle - Add prompts query and mutation atoms (atomWithQuery/atomWithMutation) with TanStack Query caching, replacing manual useEffect fetches - Update PromptPicker, PromptsContent, and CommunityPromptsContent to consume shared atoms instead of local state
23 lines
594 B
TypeScript
23 lines
594 B
TypeScript
import { atomWithQuery } from "jotai-tanstack-query";
|
|
import { promptsApiService } from "@/lib/apis/prompts-api.service";
|
|
import { cacheKeys } from "@/lib/query-client/cache-keys";
|
|
|
|
export const promptsAtom = atomWithQuery(() => {
|
|
return {
|
|
queryKey: cacheKeys.prompts.all(),
|
|
staleTime: 5 * 60 * 1000,
|
|
queryFn: async () => {
|
|
return promptsApiService.list();
|
|
},
|
|
};
|
|
});
|
|
|
|
export const publicPromptsAtom = atomWithQuery(() => {
|
|
return {
|
|
queryKey: cacheKeys.prompts.public(),
|
|
staleTime: 2 * 60 * 1000,
|
|
queryFn: async () => {
|
|
return promptsApiService.listPublic();
|
|
},
|
|
};
|
|
});
|