Skip to content
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

[WEB-1322] dev: conflict free pages collaboration #4463

Merged
merged 44 commits into from
May 26, 2024

Conversation

aaryan610
Copy link
Collaborator

@aaryan610 aaryan610 commented May 15, 2024

What's new?

Pages now support a conflict-free data merging along with OFFLINE editing.

Implementation

Added yjs to efficiently manage conflicts in pages. When on a page, new data gets fetched every 10 seconds and if there's anything new, the changes get merged without any conflicts with the local changes, removing the risk of data loss.

Apart from this, along with the auto-save logic, users can now hit Ctrl/Cmd + S or click on the Save changes button to save their data.

Custom provider

Created a custom provider- CollaborationProvider to handle updates on the page

export interface CompleteCollaboratorProviderConfiguration {
  /**
   * The identifier/name of your document
   */
  name: string;
  /**
   * The actual Y.js document
   */
  document: Y.Doc;
  /**
   * onChange callback
   */
  onChange: (updates: Uint8Array) => void;
}
  1. name- Uniquely identifier for each page.
  2. document- Actual YDoc to read from and write on.
  3. onChange- Callback to handle updates.

The main function of the provider is to handle updates on the document. All the updates performed in a time window of 2 seconds are merged using mergeUpdates from yjs and then the onChange callback is triggered using this merge updates.

IndexedDB for offline support

Added y-indexeddb to handle changes made when the client is offline, all of the updates made(online and offline) are stored in the indexedDB and on reconnecting, these changes are applied to the YDoc. These changes are then listened by the CollaborationProvider which triggers the onChange callback with these updates.

Fixes- #1880

Plane issue: WEB-1322

NarayanBavisetti and others added 23 commits May 8, 2024 13:47
@aaryan610 aaryan610 added this to the v0.20-dev milestone May 15, 2024
@aaryan610 aaryan610 marked this pull request as draft May 15, 2024 12:37
@aaryan610 aaryan610 marked this pull request as ready for review May 17, 2024 12:36
@pushya22 pushya22 marked this pull request as draft May 20, 2024 13:51
web/hooks/use-page-description.ts Outdated Show resolved Hide resolved
@aaryan610 aaryan610 marked this pull request as ready for review May 22, 2024 11:44
@sriramveeraghanta sriramveeraghanta changed the base branch from preview to develop May 26, 2024 11:06
@sriramveeraghanta sriramveeraghanta merged commit 90d5dd5 into develop May 26, 2024
13 of 14 checks passed
@sriramveeraghanta sriramveeraghanta deleted the feat-pages-collaboration branch May 26, 2024 11:07
sriramveeraghanta pushed a commit that referenced this pull request May 27, 2024
* chore: pages realtime

* chore: empty binary response

* chore: added a ypy package

* feat: pages collaboration

* chore: update fetching logic

* chore: degrade ypy version

* chore: replace useEffect fetch logic with useSWR

* chore: move all the update logic to the page store

* refactor: remove react-hook-form

* chore: save description_html as well

* chore: migrate old data logic

* fix: added description_binary as field name

* fix: code cleanup

* refactor: create separate hook to handle page description

* fix: build errors

* chore: combine updates instead of using the whole document

* chore: removed ypy package

* chore: added conflict resolving logic to the client side

* chore: add a save changes button

* chore: add read-only validation

* chore: remove saving state information

* chore: added permission class

* chore: removed the migration file

* chore: corrected the model field

* chore: rename pageStore to page

* chore: update collaboration provider

* chore: add try catch to handle error

---------

Co-authored-by: NarayanBavisetti <narayan3119@gmail.com>
sriramveeraghanta pushed a commit that referenced this pull request May 28, 2024
* chore: pages realtime

* chore: empty binary response

* chore: added a ypy package

* feat: pages collaboration

* chore: update fetching logic

* chore: degrade ypy version

* chore: replace useEffect fetch logic with useSWR

* chore: move all the update logic to the page store

* refactor: remove react-hook-form

* chore: save description_html as well

* chore: migrate old data logic

* fix: added description_binary as field name

* fix: code cleanup

* refactor: create separate hook to handle page description

* fix: build errors

* chore: combine updates instead of using the whole document

* chore: removed ypy package

* chore: added conflict resolving logic to the client side

* chore: add a save changes button

* chore: add read-only validation

* chore: remove saving state information

* chore: added permission class

* chore: removed the migration file

* chore: corrected the model field

* chore: rename pageStore to page

* chore: update collaboration provider

* chore: add try catch to handle error

---------

Co-authored-by: NarayanBavisetti <narayan3119@gmail.com>
@srinivaspendem srinivaspendem modified the milestones: v0.20-dev, v0.21-dev May 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants