Hi everyone, so currently I’m developing a collaborative room-based graph-editor app using yjs and y-webrtc, and the app works like this (mostly like google docs):
- When first starting the app, a new empty room will be created for you with a room id.
- You can share your room id with your peers so they can join your room.
- User’s in this app can join other rooms from any room.
- When a user leaves a room, the user’s local CRDT state from last room will be deleted, and the CRDT state of the new room will be loaded as the new local state.
Now, I’m encountering a bug at step (4), that SOMETIMES when user A joins user B’s room, instead of user A seeing user B’s last state, the opposite happens (user B’ state will be overwritten by user A, which is a very very bad user experience). I’ve done some digging about this issue and found that this is the intended behaviour of CRDT’s sync mechanism.
Is there a way to tell the network provider to ignore (or delete) the local state when changing room id so instead of merging user A and user B’s state, it will just use user B’s state entirely? I’ve tried using
ydoc.destroy() but the bug is still occuring.
Thanks in advance for your help!!