mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-21 02:40:14 +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,5 @@
|
|||
import { useCallback } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useSetRecoilState, useResetRecoilState, useRecoilCallback } from 'recoil';
|
||||
import { useGetEndpointsQuery } from 'librechat-data-provider';
|
||||
import type {
|
||||
|
|
@ -12,6 +13,7 @@ import { buildDefaultConvo, getDefaultEndpoint } from '~/utils';
|
|||
import store from '~/store';
|
||||
|
||||
const useConversation = () => {
|
||||
const navigate = useNavigate();
|
||||
const setConversation = useSetRecoilState(store.conversation);
|
||||
const setMessages = useSetRecoilState<TMessagesAtom>(store.messages);
|
||||
const setSubmission = useSetRecoilState<TSubmission | null>(store.submission);
|
||||
|
|
@ -48,6 +50,10 @@ const useConversation = () => {
|
|||
setMessages(messages);
|
||||
setSubmission({} as TSubmission);
|
||||
resetLatestMessage();
|
||||
|
||||
if (conversation.conversationId === 'new') {
|
||||
navigate('/chat/new');
|
||||
}
|
||||
},
|
||||
[endpointsConfig],
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue