Merge pull request #2362 from automatisch/AUT-1433
feat: debounce onAddStep in EditorNew
This commit is contained in:
@@ -3,6 +3,7 @@ import { useQueryClient } from '@tanstack/react-query';
|
|||||||
import { FlowPropType } from 'propTypes/propTypes';
|
import { FlowPropType } from 'propTypes/propTypes';
|
||||||
import ReactFlow, { useNodesState, useEdgesState } from 'reactflow';
|
import ReactFlow, { useNodesState, useEdgesState } from 'reactflow';
|
||||||
import 'reactflow/dist/style.css';
|
import 'reactflow/dist/style.css';
|
||||||
|
import { debounce } from 'lodash';
|
||||||
|
|
||||||
import useCreateStep from 'hooks/useCreateStep';
|
import useCreateStep from 'hooks/useCreateStep';
|
||||||
import useUpdateStep from 'hooks/useUpdateStep';
|
import useUpdateStep from 'hooks/useUpdateStep';
|
||||||
@@ -108,11 +109,10 @@ const EditorNew = ({ flow }) => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const onAddStep = useCallback(
|
const onAddStep = useCallback(
|
||||||
async (previousStepId) => {
|
debounce(async (previousStepId) => {
|
||||||
const { data: createdStep } = await createStep({ previousStepId });
|
const { data: createdStep } = await createStep({ previousStepId });
|
||||||
|
|
||||||
createdStepIdRef.current = createdStep.id;
|
createdStepIdRef.current = createdStep.id;
|
||||||
},
|
}, 300),
|
||||||
[createStep],
|
[createStep],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user