From 2f33ec7ad07db037482ef5cfa58df1b3dd0727a5 Mon Sep 17 00:00:00 2001 From: balibabu Date: Sat, 14 Sep 2024 18:39:13 +0800 Subject: [PATCH] feat: When voice is turned on, the page will not display an empty reply message when the answer is empty #1877 (#2447) ### What problem does this PR solve? feat: When voice is turned on, the page will not display an empty reply message when the answer is empty #1877 ### Type of change - [x] New Feature (non-breaking change which adds functionality) --- web/src/hooks/chat-hooks.ts | 15 ++++++++++++--- web/src/pages/chat/hooks.ts | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/web/src/hooks/chat-hooks.ts b/web/src/hooks/chat-hooks.ts index e5e29dac693..91054c75b5d 100644 --- a/web/src/hooks/chat-hooks.ts +++ b/web/src/hooks/chat-hooks.ts @@ -95,7 +95,12 @@ export const useSetNextDialog = () => { mutationFn: async (params: IDialog) => { const { data } = await chatService.setDialog(params); if (data.retcode === 0) { - queryClient.invalidateQueries({ queryKey: ['fetchDialogList'] }); + queryClient.invalidateQueries({ + queryKey: ['fetchDialogList'], + }); + queryClient.invalidateQueries({ + queryKey: ['fetchDialog'], + }); message.success( i18n.t(`message.${params.dialog_id ? 'modified' : 'created'}`), ); @@ -110,7 +115,11 @@ export const useSetNextDialog = () => { export const useFetchNextDialog = () => { const { dialogId } = useGetChatSearchParams(); - const { data, isFetching: loading } = useQuery({ + const { + data, + isFetching: loading, + refetch, + } = useQuery({ queryKey: ['fetchDialog', dialogId], gcTime: 0, initialData: {} as IDialog, @@ -123,7 +132,7 @@ export const useFetchNextDialog = () => { }, }); - return { data, loading }; + return { data, loading, refetch }; }; export const useFetchManualDialog = () => { diff --git a/web/src/pages/chat/hooks.ts b/web/src/pages/chat/hooks.ts index 6be9e038260..b11b9e09803 100644 --- a/web/src/pages/chat/hooks.ts +++ b/web/src/pages/chat/hooks.ts @@ -429,7 +429,7 @@ export const useSendNextMessage = () => { if ( answer.answer && (answer?.conversationId === conversationId || - (!done && conversationId === '')) + ((!done || (done && answer.audio_binary)) && conversationId === '')) ) { addNewestAnswer(answer); }