Commit 2360fb29 authored by StyleZhang's avatar StyleZhang

update data

parent 1c82e387
import { useCallback } from 'react' import { useCallback } from 'react'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import produce from 'immer' import produce from 'immer'
import { debounce } from 'lodash-es'
import type { import type {
EdgeMouseHandler, EdgeMouseHandler,
NodeDragHandler, NodeDragHandler,
...@@ -50,7 +51,7 @@ export const useWorkflow = () => { ...@@ -50,7 +51,7 @@ export const useWorkflow = () => {
const nodesInitialData = useNodesInitialData() const nodesInitialData = useNodesInitialData()
const featuresStore = useFeaturesStore() const featuresStore = useFeaturesStore()
const handleSyncWorkflowDraft = useCallback(() => { const handleSyncWorkflowDraft = useCallback(debounce(() => {
const { const {
getNodes, getNodes,
edges, edges,
...@@ -83,7 +84,7 @@ export const useWorkflow = () => { ...@@ -83,7 +84,7 @@ export const useWorkflow = () => {
useStore.setState({ draftUpdatedAt: res.updated_at }) useStore.setState({ draftUpdatedAt: res.updated_at })
}) })
} }
}, [store, reactFlow, featuresStore]) }, 2000, { trailing: true }), [store, reactFlow, featuresStore])
const handleLayout = useCallback(async () => { const handleLayout = useCallback(async () => {
const { const {
...@@ -288,7 +289,8 @@ export const useWorkflow = () => { ...@@ -288,7 +289,8 @@ export const useWorkflow = () => {
currentNode.data = { ...currentNode.data, ...data } currentNode.data = { ...currentNode.data, ...data }
}) })
setNodes(newNodes) setNodes(newNodes)
}, [store]) handleSyncWorkflowDraft()
}, [store, handleSyncWorkflowDraft])
const handleNodeAddNext = useCallback(( const handleNodeAddNext = useCallback((
currentNodeId: string, 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