Identify ydoc update event

@dmonad - We use the ydoc update event in the backend(i.e. the y-websocket) to record which user and when did the change, this build the Version History as Google docs,

There is a problem when the user first loads the page(client creates the ydoc and binds with Prosemirror), it will trigger ydoc update event as well for the first sync, we can’t treat this update event as user change/activity as it is not real user update, do you have any suggestion that we can identify the update event for the first sync and avoid it?

On the backend, you could try waiting until the doc is initially synced before subscribing to update.

@raine - Appreciate your reply, I think that doesn’t work, for example, the first client already accesses the page, and the backend already initially loads the doc data and subscribed to the update event, then later the second client access that doc, the first/inital sync with backend for the second user will trigger the backend update event(which we intend to avoid) as backend already subscribed the update event.

Ah, interesting.

So the clients are not making any changes to the doc on load?

And the update on the server is non-empty?

Makes me wonder what the update actually contains.

Yeah, didn’t do any changes.
(1) The second user first accesses the page will trigger one backend update event.
(2) But if the second user refreshes the page, seems it will trigger the update event multiple times, weird, feels like multiple updates from the first user did before.

No, non-empty, this is the weird and that’s why we need to identify these updates.

Yeah, that does seem strange. I’m not sure what a non-empty update is doing if there are no changes. What is in

You could also track lastUpdated in a separate shared type. Though I’m not sure how to integrate that with your Version History.

Thanks, @raine

For now, our solution is when the editor got focused and will send a message/notification to the backend, then the backend will start to receive the update from this user, in most cases this works, but not ideal for us.