refactor(formModal): refactor code to improve readability and remove unnecessary code duplication

This commit is contained in:
anovazzi1 2023-09-28 23:38:41 -03:00 • committed by anovazzi1
commit faec3f3e56

View file

@ -220,6 +220,7 @@ export default function FormModal({
files?: Array<any>; files?: Array<any>;
}) => { }) => {
if (chatItem.message) { if (chatItem.message) {
let key = Object.keys(chatItem.message)[0];
newChatHistory.push( newChatHistory.push(
chatItem.files chatItem.files
? { ? {
@ -228,14 +229,14 @@ export default function FormModal({
template: chatItem.template, template: chatItem.template,
thought: chatItem.intermediate_steps, thought: chatItem.intermediate_steps,
files: chatItem.files, files: chatItem.files,
chatKey: chatItem.chatKey, chatKey: key,
} }
: { : {
isSend: !chatItem.is_bot, isSend: !chatItem.is_bot,
message: chatItem.message, message: chatItem.message,
template: chatItem.template, template: chatItem.template,
thought: chatItem.intermediate_steps, thought: chatItem.intermediate_steps,
chatKey: chatItem.chatKey, chatKey: key,
} }
); );
} }