mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-21 19:00:13 +01:00
feat: Add RQ to Conversation component, create temp Chat component with RQ for compare and debugging
This commit is contained in:
parent
39f53e6ddf
commit
c6d3bcd457
3 changed files with 114 additions and 12 deletions
|
|
@ -1,6 +1,6 @@
|
|||
import React, { useState, useRef } from 'react';
|
||||
import { useState, useRef, useEffect} from 'react';
|
||||
import { useRecoilState, useSetRecoilState } from 'recoil';
|
||||
|
||||
import { useUpdateConversationMutation } from '~/data-provider';
|
||||
import RenameButton from './RenameButton';
|
||||
import DeleteButton from './DeleteButton';
|
||||
import ConvoIcon from '../svg/ConvoIcon';
|
||||
|
|
@ -15,6 +15,8 @@ export default function Conversation({ conversation, retainView }) {
|
|||
const { refreshConversations } = store.useConversations();
|
||||
const { switchToConversation } = store.useConversation();
|
||||
|
||||
const updateConvoMutation = useUpdateConversationMutation(currentConversation?.conversationId);
|
||||
|
||||
const [renaming, setRenaming] = useState(false);
|
||||
const inputRef = useRef(null);
|
||||
|
||||
|
|
@ -22,7 +24,7 @@ export default function Conversation({ conversation, retainView }) {
|
|||
|
||||
const [titleInput, setTitleInput] = useState(title);
|
||||
|
||||
const rename = manualSWR(`/api/convos/update`, 'post');
|
||||
const rename = manualSWR(`/api/convos/update`, 'post');
|
||||
|
||||
const clickHandler = async () => {
|
||||
if (currentConversation?.conversationId === conversationId) {
|
||||
|
|
@ -59,16 +61,31 @@ export default function Conversation({ conversation, retainView }) {
|
|||
if (titleInput === title) {
|
||||
return;
|
||||
}
|
||||
rename.trigger({ conversationId, title: titleInput }).then(() => {
|
||||
refreshConversations();
|
||||
if (conversationId == currentConversation?.conversationId)
|
||||
setCurrentConversation(prevState => ({
|
||||
...prevState,
|
||||
title: titleInput
|
||||
}));
|
||||
});
|
||||
updateConvoMutation.mutate({ arg: { conversationId, title: titleInput }});
|
||||
|
||||
// rename.trigger({ conversationId, title: titleInput }).then(() => {
|
||||
// refreshConversations();
|
||||
// if (conversationId == currentConversation?.conversationId)
|
||||
// setCurrentConversation(prevState => ({
|
||||
// ...prevState,
|
||||
// title: titleInput
|
||||
// }));
|
||||
// });
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (updateConvoMutation.isSuccess) {
|
||||
// debugger;
|
||||
refreshConversations();
|
||||
if (conversationId == currentConversation?.conversationId)
|
||||
|
||||
setCurrentConversation(prevState => ({
|
||||
...prevState,
|
||||
title: titleInput
|
||||
}));
|
||||
}
|
||||
}, [updateConvoMutation.isSuccess]);
|
||||
|
||||
const handleKeyDown = e => {
|
||||
if (e.key === 'Enter') {
|
||||
onRename(e);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue