mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-20 18:30:15 +01:00
add delete conversation mutation, fix withAuthentication on post requests
This commit is contained in:
parent
bd53b878d4
commit
94e0636b32
5 changed files with 68 additions and 49 deletions
|
|
@ -61,30 +61,20 @@ export default function Conversation({ conversation, retainView }) {
|
|||
if (titleInput === title) {
|
||||
return;
|
||||
}
|
||||
updateConvoMutation.mutate({ arg: { conversationId, title: titleInput }});
|
||||
|
||||
// rename.trigger({ conversationId, title: titleInput }).then(() => {
|
||||
// refreshConversations();
|
||||
// if (conversationId == currentConversation?.conversationId)
|
||||
// setCurrentConversation(prevState => ({
|
||||
// ...prevState,
|
||||
// title: titleInput
|
||||
// }));
|
||||
// });
|
||||
updateConvoMutation.mutate({ conversationId, title: titleInput });
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (updateConvoMutation.isSuccess) {
|
||||
// debugger;
|
||||
refreshConversations();
|
||||
if (conversationId == currentConversation?.conversationId)
|
||||
|
||||
setCurrentConversation(prevState => ({
|
||||
...prevState,
|
||||
title: titleInput
|
||||
}));
|
||||
}
|
||||
}, [updateConvoMutation.isSuccess]);
|
||||
if (updateConvoMutation.isSuccess) {
|
||||
refreshConversations();
|
||||
if (conversationId == currentConversation?.conversationId) {
|
||||
setCurrentConversation(prevState => ({
|
||||
...prevState,
|
||||
title: titleInput
|
||||
}));
|
||||
}
|
||||
}
|
||||
}, [updateConvoMutation.isSuccess]);
|
||||
|
||||
const handleKeyDown = e => {
|
||||
if (e.key === 'Enter') {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import React from 'react';
|
||||
import { useEffect } from 'react';
|
||||
import TrashIcon from '../svg/TrashIcon';
|
||||
import CrossIcon from '../svg/CrossIcon';
|
||||
import manualSWR from '~/utils/fetchers';
|
||||
import { useRecoilValue } from 'recoil';
|
||||
import { useDeleteConversationMutation } from '~/data-provider';
|
||||
|
||||
import store from '~/store';
|
||||
|
||||
|
|
@ -10,13 +10,23 @@ export default function DeleteButton({ conversationId, renaming, cancelHandler,
|
|||
const currentConversation = useRecoilValue(store.conversation) || {};
|
||||
const { newConversation } = store.useConversation();
|
||||
const { refreshConversations } = store.useConversations();
|
||||
const { trigger } = manualSWR(`/api/convos/clear`, 'post', () => {
|
||||
if (currentConversation?.conversationId == conversationId) newConversation();
|
||||
refreshConversations();
|
||||
retainView();
|
||||
});
|
||||
|
||||
const clickHandler = () => trigger({ conversationId, source: 'button' });
|
||||
const deleteConvoMutation = useDeleteConversationMutation(conversationId);
|
||||
|
||||
useEffect(() => {
|
||||
if(deleteConvoMutation.isSuccess) {
|
||||
if (currentConversation?.conversationId == conversationId) newConversation();
|
||||
|
||||
refreshConversations();
|
||||
retainView();
|
||||
}
|
||||
}, [deleteConvoMutation.isSuccess]);
|
||||
|
||||
|
||||
const clickHandler = () => {
|
||||
deleteConvoMutation.mutate({conversationId, source: 'button' });
|
||||
};
|
||||
|
||||
const handler = renaming ? cancelHandler : clickHandler;
|
||||
|
||||
return (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue