This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

semble / src / webapp / features / cards / lib / mutations / useRemoveCardFromLibrary.tsx
899 B 25 lines
1import { useMutation, useQueryClient } from '@tanstack/react-query'; 2import { removeCardFromLibrary } from '../dal'; 3import { cardKeys } from '../cardKeys'; 4import { collectionKeys } from '@/features/collections/lib/collectionKeys'; 5import { noteKeys } from '@/features/notes/lib/noteKeys'; 6import { feedKeys } from '@/features/feeds/lib/feedKeys'; 7 8export default function useRemoveCardFromLibrary() { 9 const queryClient = useQueryClient(); 10 11 const mutation = useMutation({ 12 mutationFn: (cardId: string) => { 13 return removeCardFromLibrary(cardId); 14 }, 15 16 onSuccess: () => { 17 queryClient.invalidateQueries({ queryKey: cardKeys.all() }); 18 queryClient.invalidateQueries({ queryKey: noteKeys.all() }); 19 queryClient.invalidateQueries({ queryKey: feedKeys.all() }); 20 queryClient.invalidateQueries({ queryKey: collectionKeys.all() }); 21 }, 22 }); 23 24 return mutation; 25}