mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-23 03:40:14 +01:00
fix: convos correctly delete
This commit is contained in:
parent
17c01aa252
commit
f2b092545f
8 changed files with 28 additions and 19 deletions
|
|
@ -16,7 +16,7 @@ export default function Conversation({
|
|||
title = 'New conversation',
|
||||
bingData,
|
||||
chatGptLabel = null,
|
||||
promptPrefix = null
|
||||
promptPrefix = null,
|
||||
}) {
|
||||
const [renaming, setRenaming] = useState(false);
|
||||
const [titleInput, setTitleInput] = useState(title);
|
||||
|
|
@ -97,7 +97,7 @@ export default function Conversation({
|
|||
rename.trigger({ conversationId, title: titleInput });
|
||||
};
|
||||
|
||||
const handleKeyPress = (e) => {
|
||||
const handleKeyDown = (e) => {
|
||||
if (e.key === 'Enter') {
|
||||
onRename(e);
|
||||
}
|
||||
|
|
@ -128,7 +128,7 @@ export default function Conversation({
|
|||
value={titleInput}
|
||||
onChange={(e) => setTitleInput(e.target.value)}
|
||||
onBlur={onRename}
|
||||
onKeyPress={handleKeyPress}
|
||||
onKeyDown={handleKeyDown}
|
||||
/>
|
||||
) : (
|
||||
titleInput
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import TrashIcon from '../svg/TrashIcon';
|
|||
import CrossIcon from '../svg/CrossIcon';
|
||||
import manualSWR from '~/utils/fetchers';
|
||||
import { useDispatch } from 'react-redux';
|
||||
import { setConversation } from '~/store/convoSlice';
|
||||
import { setConversation, removeConvo } from '~/store/convoSlice';
|
||||
import { setMessages } from '~/store/messageSlice';
|
||||
|
||||
export default function DeleteButton({ conversationId, renaming, cancelHandler }) {
|
||||
|
|
@ -13,6 +13,7 @@ export default function DeleteButton({ conversationId, renaming, cancelHandler }
|
|||
'post',
|
||||
() => {
|
||||
dispatch(setMessages([]));
|
||||
dispatch(removeConvo(conversationId));
|
||||
dispatch(setConversation({ title: 'New chat', conversationId: null, parentMessageId: null }));
|
||||
}
|
||||
);
|
||||
|
|
|
|||
|
|
@ -17,17 +17,20 @@ export default function Nav() {
|
|||
};
|
||||
|
||||
const { data, isLoading, mutate } = swr(
|
||||
`http://localhost:3080/api/convos?pageNumber=${pageNumber}`
|
||||
, onSuccess);
|
||||
`http://localhost:3080/api/convos?pageNumber=${pageNumber}`,
|
||||
onSuccess
|
||||
);
|
||||
const containerRef = useRef(null);
|
||||
const scrollPositionRef = useRef(null);
|
||||
|
||||
const showMore = async () => {
|
||||
const container = containerRef.current;
|
||||
if (container) {
|
||||
scrollPositionRef.current = container.scrollTop;
|
||||
const showMore = async (increment = true) => {
|
||||
if (increment) {
|
||||
const container = containerRef.current;
|
||||
if (container) {
|
||||
scrollPositionRef.current = container.scrollTop;
|
||||
}
|
||||
dispatch(incrementPage());
|
||||
}
|
||||
dispatch(incrementPage());
|
||||
await mutate();
|
||||
};
|
||||
|
||||
|
|
@ -44,9 +47,10 @@ export default function Nav() {
|
|||
}
|
||||
}, [data]);
|
||||
|
||||
const containerClasses = isLoading && pageNumber === 1
|
||||
? 'flex flex-col gap-2 text-gray-100 text-sm h-full justify-center items-center'
|
||||
: 'flex flex-col gap-2 text-gray-100 text-sm';
|
||||
const containerClasses =
|
||||
isLoading && pageNumber === 1
|
||||
? 'flex flex-col gap-2 text-gray-100 text-sm h-full justify-center items-center'
|
||||
: 'flex flex-col gap-2 text-gray-100 text-sm';
|
||||
|
||||
return (
|
||||
<div className="dark hidden bg-gray-900 md:fixed md:inset-y-0 md:flex md:w-[260px] md:flex-col">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue