From 4ae9de76d419dba548454b038e648ef01f954ed7 Mon Sep 17 00:00:00 2001 From: balibabu Date: Wed, 7 Aug 2024 10:19:14 +0800 Subject: [PATCH] fix: Unable to create a new chat assistant after closing the edit modal #1833 (#1838) ### What problem does this PR solve? fix: Unable to create a new chat assistant after closing the edit modal #1833 ### Type of change - [x] New Feature (non-breaking change which adds functionality) --- web/src/pages/chat/hooks.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/web/src/pages/chat/hooks.ts b/web/src/pages/chat/hooks.ts index 3411b4b62..205cbfec2 100644 --- a/web/src/pages/chat/hooks.ts +++ b/web/src/pages/chat/hooks.ts @@ -244,15 +244,20 @@ export const useEditDialog = () => { showModal: showDialogEditModal, } = useSetModalState(); + const hideModal = useCallback(() => { + setDialog({} as IDialog); + hideDialogEditModal(); + }, [hideDialogEditModal]); + const onDialogEditOk = useCallback( async (dialog: IDialog) => { const ret = await submitDialog(dialog); if (ret === 0) { - hideDialogEditModal(); + hideModal(); } }, - [submitDialog, hideDialogEditModal], + [submitDialog, hideModal], ); const handleShowDialogEditModal = useCallback( @@ -277,7 +282,7 @@ export const useEditDialog = () => { initialDialog: dialog, onDialogEditOk, dialogEditVisible, - hideDialogEditModal, + hideDialogEditModal: hideModal, showDialogEditModal: handleShowDialogEditModal, clearDialog, };