mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-03-02 14:20:18 +01:00
🛠️ refactor: Improve Input Placeholder Handling and Error Management 🔄 (#1296)
* chore: identify new chat buttons with testid * fix: avoid parsing error in useSSE, which causes errorHandler to fail * fix: ensure last message isn't setting latestMessage when conversationId is `new` and text is the same due to possible re-renders * refactor: set placeholder through inputRef and useEffect * Update useSSE.ts * Update useSSE.ts
This commit is contained in:
parent
2e390596ea
commit
9b2359fc27
7 changed files with 64 additions and 23 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { useEffect } from 'react';
|
||||
import { useEffect, useRef } from 'react';
|
||||
import copy from 'copy-to-clipboard';
|
||||
import type { TMessage } from 'librechat-data-provider';
|
||||
import type { TMessageProps } from '~/common';
|
||||
|
|
@ -6,6 +6,7 @@ import Icon from '~/components/Endpoints/Icon';
|
|||
import { useChatContext } from '~/Providers';
|
||||
|
||||
export default function useMessageHelpers(props: TMessageProps) {
|
||||
const latestText = useRef('');
|
||||
const { message, currentEditId, setCurrentEditId } = props;
|
||||
|
||||
const {
|
||||
|
|
@ -26,10 +27,15 @@ export default function useMessageHelpers(props: TMessageProps) {
|
|||
useEffect(() => {
|
||||
if (!message) {
|
||||
return;
|
||||
} else if (isLast) {
|
||||
} else if (
|
||||
isLast &&
|
||||
conversation?.conversationId !== 'new' &&
|
||||
latestText.current !== message.text
|
||||
) {
|
||||
setLatestMessage({ ...message });
|
||||
latestText.current = message.text;
|
||||
}
|
||||
}, [isLast, message, setLatestMessage]);
|
||||
}, [isLast, message, setLatestMessage, conversation?.conversationId]);
|
||||
|
||||
const enterEdit = (cancel?: boolean) =>
|
||||
setCurrentEditId && setCurrentEditId(cancel ? -1 : messageId);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue