mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 17:00:15 +01:00
fix: retain scroll view on delete convo
This commit is contained in:
parent
f1aabfa543
commit
8762765dd0
4 changed files with 18 additions and 13 deletions
|
|
@ -3,7 +3,7 @@ import RenameButton from './RenameButton';
|
|||
import DeleteButton from './DeleteButton';
|
||||
import { useSelector, useDispatch } from 'react-redux';
|
||||
import { setConversation } from '~/store/convoSlice';
|
||||
import { setSubmitState, setSubmission, setStopStream, setCustomGpt, setModel, setCustomModel } from '~/store/submitSlice';
|
||||
import { setSubmission, setStopStream, setCustomGpt, setModel, setCustomModel } from '~/store/submitSlice';
|
||||
import { setMessages, setEmptyMessage } from '~/store/messageSlice';
|
||||
import { setText } from '~/store/textSlice';
|
||||
import manualSWR from '~/utils/fetchers';
|
||||
|
|
@ -14,9 +14,10 @@ export default function Conversation({
|
|||
parentMessageId,
|
||||
conversationId,
|
||||
title = 'New conversation',
|
||||
bingData,
|
||||
chatGptLabel = null,
|
||||
promptPrefix = null
|
||||
promptPrefix = null,
|
||||
bingData,
|
||||
retainView,
|
||||
}) {
|
||||
const [renaming, setRenaming] = useState(false);
|
||||
const [titleInput, setTitleInput] = useState(title);
|
||||
|
|
@ -24,7 +25,7 @@ export default function Conversation({
|
|||
const { stopStream } = useSelector((state) => state.submit);
|
||||
const inputRef = useRef(null);
|
||||
const dispatch = useDispatch();
|
||||
const { trigger, isMutating } = manualSWR(`/api/messages/${id}`, 'get');
|
||||
const { trigger } = manualSWR(`/api/messages/${id}`, 'get');
|
||||
const rename = manualSWR(`/api/convos/update`, 'post');
|
||||
|
||||
const clickHandler = async () => {
|
||||
|
|
@ -162,6 +163,7 @@ export default function Conversation({
|
|||
conversationId={id}
|
||||
renaming={renaming}
|
||||
cancelHandler={cancelHandler}
|
||||
retainView={retainView}
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import { setNewConvo, removeConvo } from '~/store/convoSlice';
|
|||
import { setMessages } from '~/store/messageSlice';
|
||||
import { setSubmission } from '~/store/submitSlice';
|
||||
|
||||
export default function DeleteButton({ conversationId, renaming, cancelHandler }) {
|
||||
export default function DeleteButton({ conversationId, renaming, cancelHandler, retainView }) {
|
||||
const dispatch = useDispatch();
|
||||
const { trigger } = manualSWR(
|
||||
`/api/convos/clear`,
|
||||
|
|
@ -17,6 +17,7 @@ export default function DeleteButton({ conversationId, renaming, cancelHandler }
|
|||
dispatch(removeConvo(conversationId));
|
||||
dispatch(setNewConvo());
|
||||
dispatch(setSubmission({}));
|
||||
retainView();
|
||||
}
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -32,10 +32,11 @@ export default function Conversations({ conversations, conversationId, showMore
|
|||
chatGptLabel={convo.chatGptLabel}
|
||||
promptPrefix={convo.promptPrefix}
|
||||
bingData={bingData}
|
||||
retainView={showMore.bind(null, false)}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
{conversations && conversations.length >= 12 && conversations.length % 12 === 0 && (
|
||||
{conversations?.length >= 12 && (
|
||||
<button
|
||||
onClick={clickHandler}
|
||||
className="btn btn-dark btn-small m-auto mb-2 flex justify-center gap-2"
|
||||
|
|
|
|||
|
|
@ -24,14 +24,15 @@ export default function Nav({ navVisible, setNavVisible }) {
|
|||
const scrollPositionRef = useRef(null);
|
||||
|
||||
const showMore = async (increment = true) => {
|
||||
if (increment) {
|
||||
const container = containerRef.current;
|
||||
if (container) {
|
||||
scrollPositionRef.current = container.scrollTop;
|
||||
}
|
||||
|
||||
if (increment) {
|
||||
dispatch(incrementPage());
|
||||
}
|
||||
await mutate();
|
||||
}
|
||||
};
|
||||
|
||||
useDidMountEffect(() => mutate(), [conversationId]);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue