developing #10
|
|
@ -566,6 +566,11 @@ function FlowchartEditorInner({ projectId, projectName, userId, userDisplayName,
|
||||||
},
|
},
|
||||||
onPersist: async (persistNodes: FlowchartNode[], persistEdges: FlowchartEdge[]) => {
|
onPersist: async (persistNodes: FlowchartNode[], persistEdges: FlowchartEdge[]) => {
|
||||||
try {
|
try {
|
||||||
|
// Auto-persist saves the current state for durability. We do NOT
|
||||||
|
// broadcast state-refresh here because CRDT already syncs nodes/edges
|
||||||
|
// via yjs-update broadcasts. Broadcasting here causes ping-pong:
|
||||||
|
// other clients fetch from DB, overwrite their local variables/characters,
|
||||||
|
// then their persist writes stale data back, causing a loop.
|
||||||
await supabase
|
await supabase
|
||||||
.from('projects')
|
.from('projects')
|
||||||
.update({
|
.update({
|
||||||
|
|
@ -577,8 +582,6 @@ function FlowchartEditorInner({ projectId, projectName, userId, userDisplayName,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.eq('id', projectId)
|
.eq('id', projectId)
|
||||||
// Notify other clients to refresh after successful auto-persist
|
|
||||||
realtimeRef.current?.broadcastStateRefresh()
|
|
||||||
} catch {
|
} catch {
|
||||||
// Persistence failure is non-critical; will retry on next change
|
// Persistence failure is non-critical; will retry on next change
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue