From 00b6af8c744a02bc00bdc9c92b42327c8f3071a9 Mon Sep 17 00:00:00 2001 From: Danny Avila <110412045+danny-avila@users.noreply.github.com> Date: Tue, 5 Dec 2023 09:38:04 -0500 Subject: [PATCH] =?UTF-8?q?fix:=20Ensure=20Message=20Send=20Requires=20Key?= =?UTF-8?q?=20=F0=9F=94=91=20(#1281)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 --- client/src/components/Chat/Input/ChatForm.tsx | 8 +++-- .../Chat/Input/Files/AttachFile.tsx | 9 ++++- client/src/components/Chat/Input/Textarea.tsx | 7 ++-- .../Chat/Menus/Endpoints/MenuItem.tsx | 7 ++-- client/src/hooks/Input/index.ts | 4 +++ client/src/hooks/{ => Input}/useDebounce.ts | 0 client/src/hooks/Input/useRequiresKey.ts | 14 ++++++++ client/src/hooks/{ => Input}/useTextarea.ts | 35 ++++++------------- client/src/hooks/{ => Input}/useUserKey.ts | 0 client/src/hooks/index.ts | 4 +-- client/src/hooks/useChatHelpers.ts | 5 +-- client/src/hooks/useMessageHandler.ts | 2 +- client/src/localization/languages/Eng.tsx | 3 ++ client/src/store/families.ts | 6 ---- 14 files changed, 54 insertions(+), 50 deletions(-) create mode 100644 client/src/hooks/Input/index.ts rename client/src/hooks/{ => Input}/useDebounce.ts (100%) create mode 100644 client/src/hooks/Input/useRequiresKey.ts rename client/src/hooks/{ => Input}/useTextarea.ts (81%) rename client/src/hooks/{ => Input}/useUserKey.ts (100%) diff --git a/client/src/components/Chat/Input/ChatForm.tsx b/client/src/components/Chat/Input/ChatForm.tsx index 632944eb8e..9fce650c83 100644 --- a/client/src/components/Chat/Input/ChatForm.tsx +++ b/client/src/components/Chat/Input/ChatForm.tsx @@ -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 (
{ @@ -42,16 +45,17 @@ export default function ChatForm({ index = 0 }) {