diff --git a/client/src/components/Conversations/DeleteButton.tsx b/client/src/components/Conversations/DeleteButton.tsx index 6ebe078c79..c664fc3818 100644 --- a/client/src/components/Conversations/DeleteButton.tsx +++ b/client/src/components/Conversations/DeleteButton.tsx @@ -1,39 +1,34 @@ +import { useCallback } from 'react'; import { useParams } from 'react-router-dom'; import { QueryKeys } from 'librechat-data-provider'; import { useQueryClient } from '@tanstack/react-query'; import type { TMessage } from 'librechat-data-provider'; -import { useLocalize, useConversations, useConversation } from '~/hooks'; import { useDeleteConversationMutation } from '~/data-provider'; import { Dialog, DialogTrigger, Label } from '~/components/ui'; import DialogTemplate from '~/components/ui/DialogTemplate'; import { TrashIcon, CrossIcon } from '~/components/svg'; +import { useLocalize, useNewConvo } from '~/hooks'; export default function DeleteButton({ conversationId, renaming, retainView, title }) { const localize = useLocalize(); const queryClient = useQueryClient(); - const { newConversation } = useConversation(); - const { refreshConversations } = useConversations(); + const { newConversation } = useNewConvo(); const { conversationId: currentConvoId } = useParams(); - const deleteConvoMutation = useDeleteConversationMutation(); + const deleteConvoMutation = useDeleteConversationMutation({ + onSuccess: () => { + if (currentConvoId === conversationId) { + newConversation(); + } + retainView(); + }, + }); - const confirmDelete = () => { + const confirmDelete = useCallback(() => { const messages = queryClient.getQueryData([QueryKeys.messages, conversationId]); const thread_id = messages?.[messages?.length - 1]?.thread_id; - deleteConvoMutation.mutate( - { conversationId, thread_id, source: 'button' }, - { - onSuccess: () => { - if (currentConvoId === conversationId) { - newConversation(); - } - - refreshConversations(); - retainView(); - }, - }, - ); - }; + deleteConvoMutation.mutate({ conversationId, thread_id, source: 'button' }); + }, [conversationId, deleteConvoMutation, queryClient]); return ( diff --git a/packages/data-provider/package.json b/packages/data-provider/package.json index a662e43aab..8dedc427ba 100644 --- a/packages/data-provider/package.json +++ b/packages/data-provider/package.json @@ -1,6 +1,6 @@ { "name": "librechat-data-provider", - "version": "0.5.2", + "version": "0.5.3", "description": "data services for librechat apps", "main": "dist/index.js", "module": "dist/index.es.js",