Supply Awareness instance to connection and observe changes#33
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
| }, | ||
| LOCAL_SYNC_PROVIDER_ORIGIN, | ||
| false | ||
| true |
There was a problem hiding this comment.
This change to the local parameter is intentional. Previously, it had no effect because we ignored it and checked the origin against a list of known local origins. Now we check transaction.local so it needs to be updated to properly reflect a local update.
There was a problem hiding this comment.
Would add this as a comment here, and or at the top of this class to make sure it's known how important it is that this is followed.
There was a problem hiding this comment.
I might prefer to just omit the argument or move to ydoc.transact (where it's not even possible to override) instead of the more verbose Y.transact syntax. Local is the default and only needs to be overridden in rare circumstances.
| }, | ||
| LOCAL_SYNC_PROVIDER_ORIGIN, | ||
| false | ||
| true |
There was a problem hiding this comment.
Would add this as a comment here, and or at the top of this class to make sure it's known how important it is that this is followed.
ingeniumed
left a comment
There was a problem hiding this comment.
I realized the undo/redo functionality is now broken in this branch. The undo/redo changes are visible on the remote client, but not on the local client.
undobug.mp4
|
Figured it out - it's because the transaction is a local one for the local client. The origin should also be checked in such cases to see if it's the undo manager or not. Something like the following will fix this if ( transaction.local && ( ! transaction.origin || ! ( typeof transaction.origin === 'object' && transaction.origin instanceof Y.UndoManager ) ) ) {
return;
}The idea for when the updates should be applied:
In any other case, the default behaviour of "if its not the origin we want, ignore it" should apply. |
|
Warning: Type of PR label mismatch To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.
Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task. |
|
Size Change: +195 B (+0.01%) Total Size: 1.93 MB
ℹ️ View Unchanged
|
👍 Done in d2fff34 |
What?
Three related changes here:
SyncProviderin control of creating theAwarenessinstance (if supported) and store on entity state. This will be needed as we incorporate awareness / presence features from our plugin. Passing the awareness instance to the connection function gives extenders access to it early, which is needed to catch events that happen on connection or soon after..observe/.observeDeeplisteners for each root-level CRDT map instead of a single global.on( 'update' )listener. This allows us to organize our listener code and provides better performance.