mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-08 23:32:40 +02:00
add delete chat mutation
This commit is contained in:
parent
b866170e6a
commit
43362a383e
1 changed files with 4 additions and 3 deletions
|
|
@ -4,6 +4,7 @@ import { activeSearchSpaceIdAtom } from "../../seach-spaces/active-seach-space.a
|
|||
import { queryClient } from "@/lib/query-client/client";
|
||||
import { cacheKeys } from "@/lib/query-client/cache-keys";
|
||||
import { toast } from "sonner";
|
||||
import { Chat } from "@/app/dashboard/[search_space_id]/chats/chats-client";
|
||||
|
||||
export const deleteChatMutationAtom = atomWithMutation((get) => {
|
||||
const searchSpaceId = get(activeSearchSpaceIdAtom);
|
||||
|
|
@ -23,10 +24,10 @@ export const deleteChatMutationAtom = atomWithMutation((get) => {
|
|||
return deleteChat(chatId, authToken);
|
||||
},
|
||||
|
||||
onSuccess: () => {
|
||||
onSuccess: (_, chatId) => {
|
||||
toast.success("Chat deleted successfully");
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: cacheKeys.activeSearchSpace.chats(searchSpaceId!),
|
||||
queryClient.setQueryData(cacheKeys.activeSearchSpace.chats(searchSpaceId!), (oldData: Chat[]) => {
|
||||
return oldData.filter((chat) => chat.id !== chatId);
|
||||
});
|
||||
},
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue