mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 17:00:15 +01:00
fix: Ensure Message Send Requires Key 🔑 (#1281)
* fix: only allow message send when key is provided when required - create useRequiresKey hook - pass same disabled prop to Textarea, AttachFile, and SendButton - EndpointItem: add localization, stopPropagation, and remove commented code - separate some hooks to new Input dir - completely remove textareaHeight recoil state as is not needed - update imports for moved hooks - pass disabled prop to useTextarea * feat: add localization to textarea placeholders
This commit is contained in:
parent
f6118879e5
commit
00b6af8c74
14 changed files with 54 additions and 50 deletions
|
|
@ -1,6 +1,7 @@
|
|||
import { useRecoilState } from 'recoil';
|
||||
import type { ChangeEvent } from 'react';
|
||||
import { useChatContext } from '~/Providers';
|
||||
import { useRequiresKey } from '~/hooks';
|
||||
import AttachFile from './Files/AttachFile';
|
||||
import StopButton from './StopButton';
|
||||
import SendButton from './SendButton';
|
||||
|
|
@ -28,6 +29,8 @@ export default function ChatForm({ index = 0 }) {
|
|||
setText('');
|
||||
};
|
||||
|
||||
const { requiresKey } = useRequiresKey();
|
||||
|
||||
return (
|
||||
<form
|
||||
onSubmit={(e) => {
|
||||
|
|
@ -42,16 +45,17 @@ export default function ChatForm({ index = 0 }) {
|
|||
<Images files={files} setFiles={setFiles} setFilesLoading={setFilesLoading} />
|
||||
<Textarea
|
||||
value={text}
|
||||
disabled={requiresKey}
|
||||
onChange={(e: ChangeEvent<HTMLTextAreaElement>) => setText(e.target.value)}
|
||||
setText={setText}
|
||||
submitMessage={submitMessage}
|
||||
endpoint={conversation?.endpoint}
|
||||
/>
|
||||
<AttachFile endpoint={conversation?.endpoint ?? ''} />
|
||||
<AttachFile endpoint={conversation?.endpoint ?? ''} disabled={requiresKey} />
|
||||
{isSubmitting && showStopButton ? (
|
||||
<StopButton stop={handleStopGenerating} setShowStopButton={setShowStopButton} />
|
||||
) : (
|
||||
<SendButton text={text} disabled={filesLoading || isSubmitting} />
|
||||
<SendButton text={text} disabled={filesLoading || isSubmitting || requiresKey} />
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue