2025-04-18 13:59:12 +08:00
|
|
|
import { useCallback } from 'react'
|
2025-10-20 13:49:26 +08:00
|
|
|
import { produce } from 'immer'
|
2025-04-18 13:59:12 +08:00
|
|
|
import { useStoreApi } from 'reactflow'
|
|
|
|
|
|
|
|
|
|
export const useEdgesInteractionsWithoutSync = () => {
|
|
|
|
|
const store = useStoreApi()
|
|
|
|
|
|
|
|
|
|
const handleEdgeCancelRunningStatus = useCallback(() => {
|
|
|
|
|
const {
|
|
|
|
|
edges,
|
|
|
|
|
setEdges,
|
|
|
|
|
} = store.getState()
|
|
|
|
|
|
|
|
|
|
const newEdges = produce(edges, (draft) => {
|
|
|
|
|
draft.forEach((edge) => {
|
|
|
|
|
edge.data._sourceRunningStatus = undefined
|
|
|
|
|
edge.data._targetRunningStatus = undefined
|
|
|
|
|
edge.data._waitingRun = false
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
setEdges(newEdges)
|
|
|
|
|
}, [store])
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
handleEdgeCancelRunningStatus,
|
|
|
|
|
}
|
|
|
|
|
}
|