mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-21 18:55:16 +02:00
refactor: consolidate public chat snapshot mutations with cache invalidation
This commit is contained in:
parent
67f797232e
commit
ee56334abe
5 changed files with 41 additions and 35 deletions
|
|
@ -5,7 +5,7 @@ import { useAtomValue, useSetAtom } from "jotai";
|
|||
import { Globe, User, Users } from "lucide-react";
|
||||
import { useCallback, useMemo, useState } from "react";
|
||||
import { toast } from "sonner";
|
||||
import { createPublicChatSnapshotMutationAtom } from "@/atoms/chat/chat-thread-mutation.atoms";
|
||||
import { createPublicChatSnapshotMutationAtom } from "@/atoms/public-chat-snapshots/public-chat-snapshots-mutation.atoms";
|
||||
import { currentThreadAtom, setThreadVisibilityAtom } from "@/atoms/chat/current-thread.atom";
|
||||
import { myAccessAtom } from "@/atoms/members/members-query.atoms";
|
||||
import { Button } from "@/components/ui/button";
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ export function PublicChatSnapshotsManager({
|
|||
const [deletingId, setDeletingId] = useState<number | undefined>();
|
||||
|
||||
// Data fetching
|
||||
const { data: snapshotsData, isLoading, isError, refetch } = useAtomValue(publicChatSnapshotsAtom);
|
||||
const { data: snapshotsData, isLoading, isError } = useAtomValue(publicChatSnapshotsAtom);
|
||||
|
||||
// Permissions
|
||||
const { data: access } = useAtomValue(myAccessAtom);
|
||||
|
|
@ -57,14 +57,13 @@ export function PublicChatSnapshotsManager({
|
|||
thread_id: snapshot.thread_id,
|
||||
snapshot_id: snapshot.id,
|
||||
});
|
||||
await refetch();
|
||||
} catch (error) {
|
||||
console.error("Failed to delete snapshot:", error);
|
||||
} finally {
|
||||
setDeletingId(undefined);
|
||||
}
|
||||
},
|
||||
[deleteSnapshot, refetch]
|
||||
[deleteSnapshot]
|
||||
);
|
||||
|
||||
// Loading state
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue