mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-16 16:30:15 +01:00
🔧 fix: Immutability Issue in useChatFunctions (#7983)
* fix: Use mutable version of conversation in useChatFunctions * fix: Use cloneDeep for conversation in useChatFunctions to ensure immutability --------- Co-authored-by: lucioperca <lucioperca@users.noreply.github.com>
This commit is contained in:
parent
a5e8d009a1
commit
d53cd1f391
1 changed files with 5 additions and 2 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import { v4 } from 'uuid';
|
||||
import { cloneDeep } from 'lodash';
|
||||
import { useQueryClient } from '@tanstack/react-query';
|
||||
import {
|
||||
Constants,
|
||||
|
|
@ -51,10 +52,10 @@ export default function useChatFunctions({
|
|||
getMessages,
|
||||
setMessages,
|
||||
isSubmitting,
|
||||
conversation,
|
||||
latestMessage,
|
||||
setSubmission,
|
||||
setLatestMessage,
|
||||
conversation: immutableConversation,
|
||||
}: {
|
||||
index?: number;
|
||||
isSubmitting: boolean;
|
||||
|
|
@ -77,8 +78,8 @@ export default function useChatFunctions({
|
|||
const isTemporary = useRecoilValue(store.isTemporary);
|
||||
const codeArtifacts = useRecoilValue(store.codeArtifacts);
|
||||
const includeShadcnui = useRecoilValue(store.includeShadcnui);
|
||||
const { getExpiry } = useUserKey(conversation?.endpoint ?? '');
|
||||
const customPromptMode = useRecoilValue(store.customPromptMode);
|
||||
const { getExpiry } = useUserKey(immutableConversation?.endpoint ?? '');
|
||||
const setShowStopButton = useSetRecoilState(store.showStopButtonByIndex(index));
|
||||
const resetLatestMultiMessage = useResetRecoilState(store.latestMessageFamily(index + 1));
|
||||
|
||||
|
|
@ -108,6 +109,8 @@ export default function useChatFunctions({
|
|||
return;
|
||||
}
|
||||
|
||||
const conversation = cloneDeep(immutableConversation);
|
||||
|
||||
const endpoint = conversation?.endpoint;
|
||||
if (endpoint === null) {
|
||||
console.error('No endpoint available');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue