mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-17 18:35:19 +02:00
Fix create_prompt is_public bug, conditional version bump, and add Jotai prompts atoms
- 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
This commit is contained in:
parent
95620a4331
commit
5f4f7780d1
7 changed files with 184 additions and 88 deletions
23
surfsense_web/atoms/prompts/prompts-query.atoms.ts
Normal file
23
surfsense_web/atoms/prompts/prompts-query.atoms.ts
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
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();
|
||||
},
|
||||
};
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue