developing #10

Merged
GHMiranda merged 64 commits from developing into master 2026-01-25 00:37:11 +00:00
2 changed files with 15 additions and 0 deletions
Showing only changes of commit fa8437d03a - Show all commits

View File

@ -605,6 +605,8 @@ function FlowchartEditorInner({ projectId, projectName, userId, userDisplayName,
...prev, ...prev,
{ id: nanoid(), displayName: user.displayName, type: 'join', color: getUserColor(user.userId) }, { id: nanoid(), displayName: user.displayName, type: 'join', color: getUserColor(user.userId) },
]) ])
// Send full CRDT state so the joining client gets caught up
crdtManager.broadcastFullState()
}, },
onPresenceLeave: (user) => { onPresenceLeave: (user) => {
setCollaborationNotifications((prev) => [ setCollaborationNotifications((prev) => [

View File

@ -63,6 +63,19 @@ export class CRDTManager {
/** Connect to a Supabase Realtime channel for outbound broadcasts */ /** Connect to a Supabase Realtime channel for outbound broadcasts */
connectChannel(channel: RealtimeChannel): void { connectChannel(channel: RealtimeChannel): void {
this.channel = channel this.channel = channel
// Broadcast full state so other clients merge any updates they missed
this.broadcastFullState()
}
/** Broadcast the full Yjs document state to sync all connected clients */
broadcastFullState(): void {
if (!this.channel || this.isDestroyed) return
const state = Y.encodeStateAsUpdate(this.doc)
this.channel.send({
type: 'broadcast',
event: BROADCAST_EVENT,
payload: { update: Array.from(state) },
})
} }
/** Apply a remote CRDT update received via broadcast */ /** Apply a remote CRDT update received via broadcast */