mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-29 02:46:25 +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
|
|
@ -41,6 +41,7 @@ async def create_prompt(
|
|||
name=body.name,
|
||||
prompt=body.prompt,
|
||||
mode=body.mode,
|
||||
is_public=body.is_public,
|
||||
)
|
||||
session.add(prompt)
|
||||
await session.commit()
|
||||
|
|
@ -65,10 +66,15 @@ async def update_prompt(
|
|||
if not prompt:
|
||||
raise HTTPException(status_code=404, detail="Prompt not found")
|
||||
|
||||
for field, value in body.model_dump(exclude_unset=True).items():
|
||||
updates = body.model_dump(exclude_unset=True)
|
||||
content_fields = {"name", "prompt", "mode"}
|
||||
has_content_change = bool(updates.keys() & content_fields)
|
||||
|
||||
for field, value in updates.items():
|
||||
setattr(prompt, field, value)
|
||||
|
||||
prompt.version = (prompt.version or 0) + 1
|
||||
if has_content_change:
|
||||
prompt.version = (prompt.version or 0) + 1
|
||||
|
||||
session.add(prompt)
|
||||
await session.commit()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue