Skip to content

Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active

*️⃣ refactor(DeleteButton): Conversation List Behavior after Deletion (#2414)

Danny Avila2cc580ba5278
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<TMessage[]>([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 (
<Dialog>
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",