plane icon indicating copy to clipboard operation
plane copied to clipboard

fix: add lock unlock archive restore realtime sync

Open Palanikannan1437 opened this issue 1 year ago • 1 comments

Description

All events regarding Pages (Lock, Unlock, Archive, Restore) are now realtime!

Minor fixes

  1. Fixed some states of the read only editor.
  2. Stopped an extra update on the editor when loading images at the start.

Palanikannan1437 avatar Sep 17 '24 15:09 Palanikannan1437

Walkthrough

The changes in this pull request introduce several enhancements across various components and hooks related to collaborative editing. Key modifications include the addition of the onStateless method in the HocusPocus server for broadcasting client events, improvements to error handling in image components, and the introduction of new types and methods for real-time updates in editor hooks. Additionally, several components have been refactored to streamline their logic and enhance type safety, particularly in relation to collaborative actions and document events.

Changes

File Path Change Summary
live/src/core/hocuspocus-server.ts Added async method onStateless for broadcasting client events; imported DocumentCollaborativeEvents and TDocumentEventsServer types.
packages/editor/src/core/extensions/custom-image/components/image-block.tsx Enhanced error handling during image loading; updated resizing logic and conditional rendering of image utilities.
packages/editor/src/core/extensions/custom-image/components/image-node.tsx Streamlined logic for determining editor container; simplified useEffect dependencies.
packages/editor/src/core/extensions/slash-commands/command-menu.tsx Modified keyboard navigation logic to improve robustness by adding optional chaining.
packages/editor/src/core/hooks/use-collaborative-editor.ts Removed useLayoutEffect for IndexeddbPersistence, now using useMemo; consolidated cleanup logic for providers.
packages/editor/src/core/hooks/use-editor.ts Added new methods emitRealTimeUpdate and listenToRealTimeUpdate for real-time updates; updated type definitions.
packages/editor/src/core/hooks/use-read-only-collaborative-editor.ts Adjusted initialization of HocuspocusProvider and introduced localProvider with improved resource management.
packages/editor/src/core/hooks/use-read-only-editor.ts Enhanced functionality with new methods for real-time updates; imported new types.
packages/editor/src/core/types/editor.ts Added methods for handling real-time updates to EditorReadOnlyRefApi.
packages/editor/src/core/types/index.ts Added export for document-collaborative-events.
packages/editor/src/lib.ts Added exports for collaborative events and server event helpers.
packages/ui/src/icons/index.ts Exported type ISvgIcons for enhanced type safety.
web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/pages/(detail)/[pageId]/page.tsx Updated useSWR configuration for revalidation on stale data, focus, and reconnect.
web/core/components/pages/editor/editor-body.tsx Updated dependencies in serverHandler for better responsiveness; improved error logging for WebSocket URL construction.
web/core/components/pages/editor/header/options-dropdown.tsx Refactored collaborative actions to utilize executeCollaborativeAction for state changes; added type safety for icons.
web/core/hooks/use-collaborative-page-actions.tsx Introduced useCollaborativePageActions hook for managing collaborative actions with state tracking and event handling.
packages/editor/src/core/constants/document-collaborative-events.ts Introduced DocumentCollaborativeEvents constant for defining collaborative event types.
packages/editor/src/core/helpers/get-document-server-event.ts Added getServerEventName function for mapping client events to server events.
packages/editor/src/core/types/document-collaborative-events.ts Introduced types for managing collaborative events, including TDocumentEventKey, TDocumentEventsClient, TDocumentEventsServer, and TDocumentEventEmitter.
web/core/store/pages/page.ts Added optional parameter shouldSync to lock, unlock, archive, and restore methods for controlling synchronization with the backend.

Possibly related PRs

  • #5057: Introduces onStateless method to HocusPocus server configuration, related to real-time synchronization.
  • #5417: Modifies the useCollaborativeEditor hook, directly related to the collaborative features enhanced in this PR.
  • #5636: Addresses issues with real-time updates in the editor, connecting to the event broadcasting functionality of the onStateless method.
  • #5901: Enhancements related to real-time updates and user interactions, which align with the main PR's focus on event broadcasting.
  • #5974: Modifications to user configurations that relate to event handling and state management in the collaborative editor context.

Suggested labels

✨feature, 🌐frontend, ⚙️backend

Suggested reviewers

  • SatishGandham
  • aaryan610

🐰 In a world where documents flow,
Real-time updates steal the show.
With images that load and resize with grace,
Collaboration now finds its place.
So hop along, let’s celebrate,
These changes make our work first-rate! 🥕✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

coderabbitai[bot] avatar Sep 17 '24 15:09 coderabbitai[bot]