mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 17:00:15 +01:00
fix: force navigation to /chat/new on endpoint change and conversation deletions (#1141)
This commit is contained in:
parent
0886441461
commit
a2ee57568a
7 changed files with 76 additions and 61 deletions
|
|
@ -1,4 +1,3 @@
|
|||
import { useEffect } from 'react';
|
||||
import TrashIcon from '../svg/TrashIcon';
|
||||
import CrossIcon from '../svg/CrossIcon';
|
||||
import { useRecoilValue } from 'recoil';
|
||||
|
|
@ -13,24 +12,25 @@ export default function DeleteButton({ conversationId, renaming, retainView, tit
|
|||
const currentConversation = useRecoilValue(store.conversation) || {};
|
||||
const { newConversation } = useConversation();
|
||||
const { refreshConversations } = useConversations();
|
||||
|
||||
const confirmDelete = () => {
|
||||
deleteConvoMutation.mutate({ conversationId, source: 'button' });
|
||||
};
|
||||
|
||||
const deleteConvoMutation = useDeleteConversationMutation(conversationId);
|
||||
|
||||
useEffect(() => {
|
||||
if (deleteConvoMutation.isSuccess) {
|
||||
if ((currentConversation as { conversationId?: string }).conversationId == conversationId) {
|
||||
newConversation();
|
||||
}
|
||||
const confirmDelete = () => {
|
||||
deleteConvoMutation.mutate(
|
||||
{ conversationId, source: 'button' },
|
||||
{
|
||||
onSuccess: () => {
|
||||
if (
|
||||
(currentConversation as { conversationId?: string }).conversationId == conversationId
|
||||
) {
|
||||
newConversation();
|
||||
}
|
||||
|
||||
refreshConversations();
|
||||
retainView();
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [deleteConvoMutation.isSuccess]);
|
||||
refreshConversations();
|
||||
retainView();
|
||||
},
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<Dialog>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue