Commit 2360fb29 authored by StyleZhang's avatar StyleZhang

update data

parent 1c82e387
import { useCallback } from 'react'
import { useTranslation } from 'react-i18next'
import produce from 'immer'
import { debounce } from 'lodash-es'
import type {
EdgeMouseHandler,
NodeDragHandler,
......@@ -50,7 +51,7 @@ export const useWorkflow = () => {
const nodesInitialData = useNodesInitialData()
const featuresStore = useFeaturesStore()
const handleSyncWorkflowDraft = useCallback(() => {
const handleSyncWorkflowDraft = useCallback(debounce(() => {
const {
getNodes,
edges,
......@@ -83,7 +84,7 @@ export const useWorkflow = () => {
useStore.setState({ draftUpdatedAt: res.updated_at })
})
}
}, [store, reactFlow, featuresStore])
}, 2000, { trailing: true }), [store, reactFlow, featuresStore])
const handleLayout = useCallback(async () => {
const {
......@@ -288,7 +289,8 @@ export const useWorkflow = () => {
currentNode.data = { ...currentNode.data, ...data }
})
setNodes(newNodes)
}, [store])
handleSyncWorkflowDraft()
}, [store, handleSyncWorkflowDraft])
const handleNodeAddNext = useCallback((
currentNodeId: string,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment