From fe0d6ae9087e2c440f29bf07be3c84cdcac265cf Mon Sep 17 00:00:00 2001 From: Danny Avila <110412045+danny-avila@users.noreply.github.com> Date: Thu, 4 Jan 2024 10:17:15 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20fix:=20Improve=20Endpoint=20Hand?= =?UTF-8?q?ling=20and=20Address=20Edge=20Cases=20(#1486)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(TEndpointsConfig): resolve property access issues with typesafe helper function * fix: undefined or null endpoint edge case * refactor(mapEndpoints -> endpoints): renamed module to be more general for endpoint handling, wrote unit tests, export all helpers --- client/src/components/Chat/Input/ChatForm.tsx | 22 +++-- client/src/components/Chat/Landing.tsx | 20 ++-- .../Chat/Menus/Endpoints/MenuItem.tsx | 12 +-- .../Chat/Menus/Endpoints/MenuItems.tsx | 7 +- .../Chat/Menus/Presets/PresetItems.tsx | 6 +- client/src/components/Conversations/Convo.tsx | 6 +- .../Input/EndpointMenu/EndpointItem.tsx | 8 +- client/src/components/Input/TextChat.tsx | 11 ++- .../src/hooks/Conversations/useGetSender.ts | 2 +- client/src/hooks/Conversations/usePresets.ts | 11 ++- client/src/hooks/Input/useRequiresKey.ts | 7 +- client/src/hooks/Input/useUserKey.ts | 2 +- .../src/hooks/Messages/useMessageHelpers.ts | 3 +- client/src/hooks/useChatHelpers.ts | 2 +- client/src/hooks/useConversation.ts | 7 +- client/src/hooks/useNavigateToConvo.tsx | 37 +++++++- client/src/hooks/useNewConvo.ts | 7 +- client/src/utils/buildDefaultConvo.ts | 1 + client/src/utils/endpoints.spec.ts | 94 +++++++++++++++++++ client/src/utils/endpoints.ts | 58 ++++++++++++ client/src/utils/getDefaultEndpoint.ts | 6 +- client/src/utils/index.ts | 2 +- client/src/utils/mapEndpoints.ts | 37 -------- packages/data-provider/src/types.ts | 6 +- 24 files changed, 275 insertions(+), 99 deletions(-) create mode 100644 client/src/utils/endpoints.spec.ts create mode 100644 client/src/utils/endpoints.ts delete mode 100644 client/src/utils/mapEndpoints.ts diff --git a/client/src/components/Chat/Input/ChatForm.tsx b/client/src/components/Chat/Input/ChatForm.tsx index efd6285d299..f52ff943e1f 100644 --- a/client/src/components/Chat/Input/ChatForm.tsx +++ b/client/src/components/Chat/Input/ChatForm.tsx @@ -45,19 +45,23 @@ export default function ChatForm({ index = 0 }) {
-