fix: auto send delay (#3352)

This commit is contained in:
Archer
2024-12-10 09:51:49 +08:00
committed by GitHub
parent fc8f73fc55
commit fd47f73086

View File

@@ -58,7 +58,7 @@ import dynamic from 'next/dynamic';
import type { StreamResponseType } from '@/web/common/api/fetch';
import { useContextSelector } from 'use-context-selector';
import { useSystem } from '@fastgpt/web/hooks/useSystem';
import { useCreation, useMemoizedFn, useThrottleFn } from 'ahooks';
import { useCreation, useDebounceEffect, useMemoizedFn, useThrottleFn } from 'ahooks';
import MyIcon from '@fastgpt/web/components/common/Icon';
import { mergeChatResponseData } from '@fastgpt/global/core/chat/utils';
import { getWebReqUrl } from '@fastgpt/web/common/system/utils';
@@ -380,6 +380,7 @@ const ChatBox = ({
async ({ variables = {} }) => {
if (!onStartChat) return;
if (isChatting) {
!hideInUI &&
toast({
title: t('chat:is_chatting'),
status: 'warning'
@@ -834,7 +835,8 @@ const ChatBox = ({
}, [isReady, resetInputVal, sendPrompt]);
// Auto send prompt
useEffect(() => {
useDebounceEffect(
() => {
if (
isReady &&
chatBoxData?.app?.chatConfig?.autoExecute?.open &&
@@ -847,14 +849,19 @@ const ChatBox = ({
hideInUI: true
});
}
}, [
},
[
isReady,
chatStarted,
chatRecords.length,
isChatRecordsLoaded,
sendPrompt,
chatBoxData?.app?.chatConfig?.autoExecute
]);
],
{
wait: 500
}
);
// output data
useImperativeHandle(ChatBoxRef, () => ({