-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Real-time collaboration: Refetch entity when it is saved by a peer #72851
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Size Change: +223 B (+0.01%) Total Size: 2.19 MB
ℹ️ View Unchanged
|
|
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. |
maxschmeling
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we be concerned about the fact that when someone hits save, every connected collaborator will make an API call to retrieve the entity? Problematic for the site workers when there are a large number of editors? Probably not enough collaborators to be a concern.
| if ( 'number' === typeof newValue && newValue > now ) { | ||
| // Another peer has saved the record. Refetch it so that we have | ||
| // a correct understanding of our own unsaved edits. | ||
| void handlers.refetchRecord().catch( () => {} ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this fails, there is something really problematic, right? Should we actually do something in the catch?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's very rare and likely an unrecoverable error like loss of permission or network error. (Both of which would result in eventual discconnection from the editing session.) Maybe there are more possible states? I'd elect to investigate and handle them in a separate enhancement.
ee8d992 to
4baafca
Compare
Good question. I think simultaneous requests in the double digits are a non-issue for platforms like ours and any host with caching proxies. Let's see if we can observe a performance problem. |
What?
Refetch the entity when it is saved by a peer.
Why?
When editing alone, an editor always has an accurate understanding of which edits are unsaved. In other words, they know when the entity is in a "dirty" state. When collaborating with others, however, this changes. If another peer saves the entity, I no longer know which of my edits are unsaved.
How?
SyncManagerthat allows it to refetch the entity.saveEntityRecordaction creator, callsyncManager.update()with a specialisSaveargument to signal that the current user just saved the entity.Testing Instructions
Testing Instructions for Keyboard
No UI changes in this PR.