LiveEdge pulse gaps: reset timer survives other producers, snapshots do not flash, flow: endpoints pulse as their node
This commit is contained in:
@@ -89,6 +89,11 @@ function LiveEdgeComponent({
|
||||
const zoom = useStore((state) => state.transform[2])
|
||||
const [pulsing, setPulsing] = useState(false)
|
||||
const lastTs = useRef<number | null>(null)
|
||||
// Owned by the pulse rather than by the effect: a value from another
|
||||
// producer re-runs the effect too, and must not cancel a reset it does not
|
||||
// replace, or the edge stays lit and the next pulse cannot restart.
|
||||
const timer = useRef<ReturnType<typeof setTimeout>>(undefined)
|
||||
useEffect(() => () => clearTimeout(timer.current), [])
|
||||
|
||||
// Every rank sits further along the flow than the one before it, so an edge
|
||||
// whose target has ended up behind its source is one closing a cycle.
|
||||
@@ -113,13 +118,15 @@ function LiveEdgeComponent({
|
||||
useEffect(() => {
|
||||
if (!live?.ts || live.ts === lastTs.current) return
|
||||
lastTs.current = live.ts
|
||||
// A snapshot catching the page up is not a value passing now.
|
||||
if (live.prior) return
|
||||
const from = live.source
|
||||
// No source at all is an older engine; pulse rather than go silent.
|
||||
if (from && from.id !== producerId) return
|
||||
setPulsing(true)
|
||||
const timer = setTimeout(() => setPulsing(false), duration.pulse * 1000)
|
||||
return () => clearTimeout(timer)
|
||||
}, [live?.ts, live?.source, producerId])
|
||||
clearTimeout(timer.current)
|
||||
timer.current = setTimeout(() => setPulsing(false), duration.pulse * 1000)
|
||||
}, [live?.ts, live?.source, live?.prior, producerId])
|
||||
|
||||
return (
|
||||
<>
|
||||
|
||||
Reference in New Issue
Block a user