From 57f580c93d61c862c2cf0f1b553e20a3a5bdc2e5 Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Wed, 16 Aug 2023 17:52:08 -0300 Subject: [PATCH] refactor(utils.ts): simplify logic for getting chat input field The logic for getting the chat input field has been simplified by removing unnecessary checks and using optional chaining. This improves readability and reduces the complexity of the code. --- src/frontend/src/utils/utils.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/frontend/src/utils/utils.ts b/src/frontend/src/utils/utils.ts index c8e93b773..db87094f4 100644 --- a/src/frontend/src/utils/utils.ts +++ b/src/frontend/src/utils/utils.ts @@ -280,12 +280,13 @@ export function getChatInputField(flow: FlowType, tabsState?: TabsState) { let chat_input_field = "text"; if ( + tabsState && tabsState[flow.id] && tabsState[flow.id].formKeysData && tabsState[flow.id].formKeysData.input_keys ) { chat_input_field = Object.keys( - tabsState[flow.id].formKeysData.input_keys + tabsState[flow.id].formKeysData.input_keys! )[0]; } return chat_input_field;