balibabu commited on
Commit
64dd66b
·
1 Parent(s): ba91369

fix: Unable to create a new chat assistant after closing the edit modal #1833 (#1838)

Browse files

### 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)

Files changed (1) hide show
  1. web/src/pages/chat/hooks.ts +8 -3
web/src/pages/chat/hooks.ts CHANGED
@@ -244,15 +244,20 @@ export const useEditDialog = () => {
244
  showModal: showDialogEditModal,
245
  } = useSetModalState();
246
 
 
 
 
 
 
247
  const onDialogEditOk = useCallback(
248
  async (dialog: IDialog) => {
249
  const ret = await submitDialog(dialog);
250
 
251
  if (ret === 0) {
252
- hideDialogEditModal();
253
  }
254
  },
255
- [submitDialog, hideDialogEditModal],
256
  );
257
 
258
  const handleShowDialogEditModal = useCallback(
@@ -277,7 +282,7 @@ export const useEditDialog = () => {
277
  initialDialog: dialog,
278
  onDialogEditOk,
279
  dialogEditVisible,
280
- hideDialogEditModal,
281
  showDialogEditModal: handleShowDialogEditModal,
282
  clearDialog,
283
  };
 
244
  showModal: showDialogEditModal,
245
  } = useSetModalState();
246
 
247
+ const hideModal = useCallback(() => {
248
+ setDialog({} as IDialog);
249
+ hideDialogEditModal();
250
+ }, [hideDialogEditModal]);
251
+
252
  const onDialogEditOk = useCallback(
253
  async (dialog: IDialog) => {
254
  const ret = await submitDialog(dialog);
255
 
256
  if (ret === 0) {
257
+ hideModal();
258
  }
259
  },
260
+ [submitDialog, hideModal],
261
  );
262
 
263
  const handleShowDialogEditModal = useCallback(
 
282
  initialDialog: dialog,
283
  onDialogEditOk,
284
  dialogEditVisible,
285
+ hideDialogEditModal: hideModal,
286
  showDialogEditModal: handleShowDialogEditModal,
287
  clearDialog,
288
  };