mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-20 18:30: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
14
client/src/hooks/Input/useRequiresKey.ts
Normal file
14
client/src/hooks/Input/useRequiresKey.ts
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
import { useGetEndpointsQuery } from 'librechat-data-provider';
|
||||
import { useChatContext } from '~/Providers/ChatContext';
|
||||
import useUserKey from './useUserKey';
|
||||
|
||||
export default function useRequiresKey() {
|
||||
const { conversation } = useChatContext();
|
||||
const { data: endpointsConfig } = useGetEndpointsQuery();
|
||||
const { endpoint } = conversation || {};
|
||||
const userProvidesKey = endpointsConfig?.[endpoint ?? '']?.userProvide;
|
||||
const { getExpiry } = useUserKey(endpoint ?? '');
|
||||
const expiryTime = getExpiry();
|
||||
const requiresKey = !expiryTime && userProvidesKey;
|
||||
return { requiresKey };
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue