Skip to content

Commit

Permalink
feat: When voice is turned on, the page will not display an empty rep…
Browse files Browse the repository at this point in the history
…ly 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)
  • Loading branch information
cike8899 authored Sep 14, 2024
1 parent 3b1375e commit 2f33ec7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
15 changes: 12 additions & 3 deletions web/src/hooks/chat-hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'}`),
);
Expand All @@ -110,7 +115,11 @@ export const useSetNextDialog = () => {
export const useFetchNextDialog = () => {
const { dialogId } = useGetChatSearchParams();

const { data, isFetching: loading } = useQuery<IDialog>({
const {
data,
isFetching: loading,
refetch,
} = useQuery<IDialog>({
queryKey: ['fetchDialog', dialogId],
gcTime: 0,
initialData: {} as IDialog,
Expand All @@ -123,7 +132,7 @@ export const useFetchNextDialog = () => {
},
});

return { data, loading };
return { data, loading, refetch };
};

export const useFetchManualDialog = () => {
Expand Down
2 changes: 1 addition & 1 deletion web/src/pages/chat/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ export const useSendNextMessage = () => {
if (
answer.answer &&
(answer?.conversationId === conversationId ||
(!done && conversationId === ''))
((!done || (done && answer.audio_binary)) && conversationId === ''))
) {
addNewestAnswer(answer);
}
Expand Down

0 comments on commit 2f33ec7

Please sign in to comment.