mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-07-09 21:04:49 +08:00
Fix: Rapid clicking results in multiple message requests being sent. (#16739)
This commit is contained in:
@@ -126,10 +126,10 @@ export function NextMessageInput({
|
||||
}, []);
|
||||
|
||||
const submit = React.useCallback(() => {
|
||||
if (isUploading) return;
|
||||
if (isUploading || sendLoading) return;
|
||||
pressEnter();
|
||||
setFiles([]);
|
||||
}, [isUploading, pressEnter]);
|
||||
}, [isUploading, sendLoading, pressEnter]);
|
||||
|
||||
const handleKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {
|
||||
if (e.key === 'Enter' && !e.shiftKey) {
|
||||
@@ -222,6 +222,7 @@ export function NextMessageInput({
|
||||
"
|
||||
disabled={isUploading || disabled || sendLoading}
|
||||
onKeyDown={handleKeyDown}
|
||||
resize={resize}
|
||||
autoSize={{ minRows: 2, maxRows: 8 }}
|
||||
/>
|
||||
|
||||
|
||||
@@ -415,7 +415,7 @@ export const useSendAgentMessage = ({
|
||||
|
||||
const handlePressEnter = useCallback(
|
||||
({ exploreSessionId }: { exploreSessionId?: string } = {}) => {
|
||||
if (trim(value) === '') return;
|
||||
if (trim(value) === '' || !done) return;
|
||||
const msgBody = buildRequestBody(value);
|
||||
if (done) {
|
||||
setValue('');
|
||||
|
||||
@@ -147,7 +147,7 @@ export const useSendMessage = (controller: AbortController) => {
|
||||
enableThinking,
|
||||
enableInternet,
|
||||
}: NextMessageInputOnPressEnterParameter) => {
|
||||
if (trim(value) === '') return;
|
||||
if (trim(value) === '' || !done) return;
|
||||
|
||||
const data = await createConversationBeforeSendMessage(value);
|
||||
|
||||
@@ -199,10 +199,10 @@ export const useSendMessage = (controller: AbortController) => {
|
||||
},
|
||||
[
|
||||
value,
|
||||
done,
|
||||
createConversationBeforeSendMessage,
|
||||
addNewestQuestion,
|
||||
files,
|
||||
done,
|
||||
clearFiles,
|
||||
setValue,
|
||||
sendMessage,
|
||||
|
||||
@@ -132,7 +132,7 @@ export const useSendSharedMessage = () => {
|
||||
enableThinking,
|
||||
enableInternet,
|
||||
}: NextMessageInputOnPressEnterParameter) => {
|
||||
if (trim(value) === '') return;
|
||||
if (trim(value) === '' || !done) return;
|
||||
const id = uuid();
|
||||
if (done) {
|
||||
setValue('');
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
import { useGetChatSearchParams } from '@/hooks/use-chat-request';
|
||||
import { IMessage } from '@/interfaces/database/chat';
|
||||
import api from '@/utils/api';
|
||||
import { trim } from 'lodash';
|
||||
import { useCallback, useEffect } from 'react';
|
||||
import { useParams } from 'react-router';
|
||||
import { v4 as uuid } from 'uuid';
|
||||
@@ -112,6 +113,7 @@ export function useSendSingleMessage({
|
||||
...params
|
||||
}: NextMessageInputOnPressEnterParameter &
|
||||
CreateConversationBeforeSendMessageReturnType) => {
|
||||
if (trim(value) === '' || !done) return;
|
||||
const id = uuid();
|
||||
|
||||
addNewestQuestion({
|
||||
|
||||
Reference in New Issue
Block a user