mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-18 01:10:14 +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 { v4 } from 'uuid';
|
||||||
|
import { cloneDeep } from 'lodash';
|
||||||
import { useQueryClient } from '@tanstack/react-query';
|
import { useQueryClient } from '@tanstack/react-query';
|
||||||
import {
|
import {
|
||||||
Constants,
|
Constants,
|
||||||
|
|
@ -51,10 +52,10 @@ export default function useChatFunctions({
|
||||||
getMessages,
|
getMessages,
|
||||||
setMessages,
|
setMessages,
|
||||||
isSubmitting,
|
isSubmitting,
|
||||||
conversation,
|
|
||||||
latestMessage,
|
latestMessage,
|
||||||
setSubmission,
|
setSubmission,
|
||||||
setLatestMessage,
|
setLatestMessage,
|
||||||
|
conversation: immutableConversation,
|
||||||
}: {
|
}: {
|
||||||
index?: number;
|
index?: number;
|
||||||
isSubmitting: boolean;
|
isSubmitting: boolean;
|
||||||
|
|
@ -77,8 +78,8 @@ export default function useChatFunctions({
|
||||||
const isTemporary = useRecoilValue(store.isTemporary);
|
const isTemporary = useRecoilValue(store.isTemporary);
|
||||||
const codeArtifacts = useRecoilValue(store.codeArtifacts);
|
const codeArtifacts = useRecoilValue(store.codeArtifacts);
|
||||||
const includeShadcnui = useRecoilValue(store.includeShadcnui);
|
const includeShadcnui = useRecoilValue(store.includeShadcnui);
|
||||||
const { getExpiry } = useUserKey(conversation?.endpoint ?? '');
|
|
||||||
const customPromptMode = useRecoilValue(store.customPromptMode);
|
const customPromptMode = useRecoilValue(store.customPromptMode);
|
||||||
|
const { getExpiry } = useUserKey(immutableConversation?.endpoint ?? '');
|
||||||
const setShowStopButton = useSetRecoilState(store.showStopButtonByIndex(index));
|
const setShowStopButton = useSetRecoilState(store.showStopButtonByIndex(index));
|
||||||
const resetLatestMultiMessage = useResetRecoilState(store.latestMessageFamily(index + 1));
|
const resetLatestMultiMessage = useResetRecoilState(store.latestMessageFamily(index + 1));
|
||||||
|
|
||||||
|
|
@ -108,6 +109,8 @@ export default function useChatFunctions({
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const conversation = cloneDeep(immutableConversation);
|
||||||
|
|
||||||
const endpoint = conversation?.endpoint;
|
const endpoint = conversation?.endpoint;
|
||||||
if (endpoint === null) {
|
if (endpoint === null) {
|
||||||
console.error('No endpoint available');
|
console.error('No endpoint available');
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue