Skip to content

Commit 2c42871

Browse files
authored
Merge pull request #719 from xuewenjie123/fix-716
fix: #716 Rapid repeated clicking error
2 parents e8c290a + 4e289f0 commit 2c42871

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

packages/studio-query/src/app/content/header.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ import { InsertRowAboveOutlined, OrderedListOutlined, PlayCircleOutlined } from
33
import { Segmented, Button, Space, Flex } from 'antd';
44
import { IStudioQueryProps, localStorageVars } from '../context';
55
import { useContext } from '../context';
6-
6+
import { Utils } from '@graphscope/studio-components';
77
import { countLines } from '../utils';
88
import { v4 as uuidv4 } from 'uuid';
99
import ToggleButton from './toggle-button';
10-
1110
import CypherEditor from '../../components/cypher-editor';
1211
import { DrawPatternModal } from '../../components/draw-pattern-modal';
1312

13+
const { debounce } = Utils;
1414
interface IHeaderProps {
1515
connectComponent?: IStudioQueryProps['connectComponent'];
1616
displaySidebarPosition?: IStudioQueryProps['displaySidebarPosition'];
@@ -92,7 +92,7 @@ const Header: React.FunctionComponent<IHeaderProps> = props => {
9292
};
9393
});
9494
};
95-
const handleQuery = () => {
95+
const handleQuery =debounce(() => {
9696
if (editorRef.current) {
9797
const value = editorRef.current.codeEditor.getValue();
9898
if (value === '') {
@@ -120,7 +120,7 @@ const Header: React.FunctionComponent<IHeaderProps> = props => {
120120
};
121121
});
122122
}
123-
};
123+
}, 500);
124124

125125
const minRows = countLines(globalScript);
126126

packages/studio-query/src/statement/index.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ import Editor from './editor';
55
import Result from './result';
66
import { useIntl } from 'react-intl';
77
import { IEditorProps } from './typing';
8+
import { Utils } from '@graphscope/studio-components';
9+
10+
const { debounce } = Utils;
811

912
export type IStatementProps = IEditorProps & {
1013
/** 是否是当前激活的语句 */
@@ -58,7 +61,7 @@ const Statement: React.FunctionComponent<IStatementProps> = props => {
5861
}
5962
}, [active]);
6063

61-
const handleQuery = async params => {
64+
const handleQuery =debounce(async params => {
6265
if (isFetching) {
6366
onCancel && onCancel(params);
6467
updateState(preState => {
@@ -87,7 +90,8 @@ const Statement: React.FunctionComponent<IStatementProps> = props => {
8790
endTime: new Date().getTime(),
8891
};
8992
});
90-
};
93+
}, 500);
94+
9195
useEffect(() => {
9296
if (enableImmediateQuery) {
9397
console.log('enableImmediateQuery script', enableImmediateQuery, script, language);

0 commit comments

Comments
 (0)