Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is stacked on top of #343
Checklist
I translated all the newly inserted strings into German and English(NA)Motivation and Context
In realtime collaboration, sometimes patches without any apparent conflict will result in cancellation of local changes on a client. This PR fixes this issue.
Description
In realtime collaboration, one client might be in the middle of making some changes while a patch to the diagram state is received from some remote. Upon receiving a patch, the patcher will apply the received patch to its own snapshot of the state, and then the reducer will set the local state to that patched state. If unsaved local changes are not synced with patcher's snapshot, the changes will be reverted.
This particularly happens a lot with continuous syncing (using
.subscribeToAllModelChangePatches()
method for realtime collaboration), as a stream of incoming patches will repeatedly cancel local changes the user is trying to do simultaneously. Note that the patcher's snapshot is intentionally kept behind local state to ensure small continuous changes don't result in patches not being sent enough (the patcher always sends the diffs with the last discrete changes).This PR adds the option to update patcher's snapshot upon patching, and ensures the reducer will update the patcher's snapshot before merging the state with incoming patches. This solution will keep patcher's snapshot behind the local state to ensure sufficient emission of necessary patches, while resolving the issue at hand.
Steps for Testing
.subscribeToAllModelChangePatches()
method is used here,Test Coverage
Screenshots