Skip to content

Conversation

@vitorguima
Copy link
Contributor

@vitorguima vitorguima commented Jul 23, 2025

  • Abstract useMessagesListSubscriptionOnRn hook to native interface so it doesn't break web version due to import problems. In this case: expo-router won't be part of web applications so it will break when importing through the previous path.

Summary by CodeRabbit

  • New Features
    • Improved chat room subscription reliability on native platforms.
  • Bug Fixes
    • Resolved issues causing message subscription failures on the web version.
  • Chores
    • Updated package version to 1.2.7.
    • Updated changelog to reflect latest changes.

@changeset-bot
Copy link

changeset-bot bot commented Jul 23, 2025

⚠️ No Changeset found

Latest commit: 158b573

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link

coderabbitai bot commented Jul 23, 2025

Walkthrough

This change removes the React Native-specific useMessagesListSubscriptionOnRn hook from the common module, introduces a native-only useMessagesListSubscription hook, updates exports accordingly, and increments the package version to 1.2.7. The changelog is updated to reflect these adjustments.

Changes

File(s) Change Summary
packages/components/CHANGELOG.md, packages/components/package.json Updated changelog and bumped package version to 1.2.7
packages/components/modules/messages/common/graphql/subscriptions/useMessagesListSubscription.tsx Removed useMessagesListSubscriptionOnRn; simplified and retained only the web-compatible hook
packages/components/modules/messages/native/graphql/subscriptions/useMessagesListSubscription.tsx Added a native-specific useMessagesListSubscription hook managing subscription lifecycle via focus events
packages/components/modules/messages/native/index.ts Added re-export for native message subscription hook

Sequence Diagram(s)

sequenceDiagram
    participant Component (Native)
    participant useMessagesListSubscription (Native)
    participant Relay Environment

    Component (Native) ->> useMessagesListSubscription (Native): Mount (with roomId, profileId, environment)
    useMessagesListSubscription (Native) ->> useFocusEffect: Register focus callback
    useFocusEffect -->> useMessagesListSubscription (Native): On focus
    useMessagesListSubscription (Native) ->> Relay Environment: requestSubscription (start)
    useFocusEffect -->> useMessagesListSubscription (Native): On unfocus/cleanup
    useMessagesListSubscription (Native) ->> Relay Environment: Dispose subscription
Loading

Estimated code review effort

2 (~15 minutes)

Possibly related PRs

Suggested labels

approved

Suggested reviewers

  • priscilladeroode
  • anicioalexandre
  • deboracosilveira
  • nossila

Poem

A bunny hops through fields of code,
Refactoring hooks with a lightened load.
Web and native, now apart,
Each with their own subscription art.
Version bumped, the changelog sings—
Hooray for streamlined, focused things!
🐇✨

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

packages/components/modules/messages/common/graphql/subscriptions/useMessagesListSubscription.tsx

Oops! Something went wrong! :(

ESLint: 8.57.1

Error: Cannot read config file: /packages/components/.eslintrc.js
Error: Cannot find module '@baseapp-frontend/config/.eslintrc-with-restricted-paths.js'
Require stack:

  • /packages/components/.eslintrc.js
  • /node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/cli-engine/cli-engine.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/eslint/eslint.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/eslint/index.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/cli.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/bin/eslint.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1369:15)
    at defaultResolveImpl (node:internal/modules/cjs/loader:1025:19)
    at resolveForCJSWithHooks (node:internal/modules/cjs/loader:1030:22)
    at Module._load (node:internal/modules/cjs/loader:1179:37)
    at TracingChannel.traceSync (node:diagnostics_channel:322:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:235:24)
    at Module.require (node:internal/modules/cjs/loader:1449:12)
    at require (node:internal/modules/helpers:135:16)
    at Object. (/packages/components/.eslintrc.js:1:18)
    at Module._compile (node:internal/modules/cjs/loader:1692:14)
packages/components/modules/messages/native/index.ts

Oops! Something went wrong! :(

ESLint: 8.57.1

Error: Cannot read config file: /packages/components/.eslintrc.js
Error: Cannot find module '@baseapp-frontend/config/.eslintrc-with-restricted-paths.js'
Require stack:

  • /packages/components/.eslintrc.js
  • /node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/cli-engine/cli-engine.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/eslint/eslint.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/eslint/index.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/cli.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/bin/eslint.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1369:15)
    at defaultResolveImpl (node:internal/modules/cjs/loader:1025:19)
    at resolveForCJSWithHooks (node:internal/modules/cjs/loader:1030:22)
    at Module._load (node:internal/modules/cjs/loader:1179:37)
    at TracingChannel.traceSync (node:diagnostics_channel:322:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:235:24)
    at Module.require (node:internal/modules/cjs/loader:1449:12)
    at require (node:internal/modules/helpers:135:16)
    at Object. (/packages/components/.eslintrc.js:1:18)
    at Module._compile (node:internal/modules/cjs/loader:1692:14)
packages/components/modules/messages/native/graphql/subscriptions/useMessagesListSubscription.tsx

Oops! Something went wrong! :(

ESLint: 8.57.1

Error: Cannot read config file: /packages/components/.eslintrc.js
Error: Cannot find module '@baseapp-frontend/config/.eslintrc-with-restricted-paths.js'
Require stack:

  • /packages/components/.eslintrc.js
  • /node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/cli-engine/cli-engine.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/eslint/eslint.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/eslint/index.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/cli.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/bin/eslint.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1369:15)
    at defaultResolveImpl (node:internal/modules/cjs/loader:1025:19)
    at resolveForCJSWithHooks (node:internal/modules/cjs/loader:1030:22)
    at Module._load (node:internal/modules/cjs/loader:1179:37)
    at TracingChannel.traceSync (node:diagnostics_channel:322:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:235:24)
    at Module.require (node:internal/modules/cjs/loader:1449:12)
    at require (node:internal/modules/helpers:135:16)
    at Object. (/packages/components/.eslintrc.js:1:18)
    at Module._compile (node:internal/modules/cjs/loader:1692:14)
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this 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.

@sonarqubecloud
Copy link

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🔭 Outside diff range comments (1)
packages/components/modules/messages/common/graphql/subscriptions/useMessagesListSubscription.tsx (1)

32-32: Dependency array may be incomplete.

The profileId is used in the variables object (line 27) but is missing from the dependency array. This could cause the config to not update when profileId changes.

-  }, [roomId])
+  }, [roomId, profileId])
🧹 Nitpick comments (1)
packages/components/modules/messages/native/graphql/subscriptions/useMessagesListSubscription.tsx (1)

27-27: Consider enhanced error handling.

While console.error provides basic error logging, consider if additional error handling is needed for production environments (e.g., error reporting service, user notification).

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 91101a9 and 158b573.

📒 Files selected for processing (5)
  • packages/components/CHANGELOG.md (1 hunks)
  • packages/components/modules/messages/common/graphql/subscriptions/useMessagesListSubscription.tsx (1 hunks)
  • packages/components/modules/messages/native/graphql/subscriptions/useMessagesListSubscription.tsx (1 hunks)
  • packages/components/modules/messages/native/index.ts (1 hunks)
  • packages/components/package.json (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: Build and Lint Packages
  • GitHub Check: Component Test Packages
🔇 Additional comments (5)
packages/components/package.json (1)

4-4: Version bump looks appropriate.

The minor version increment from 1.2.6 to 1.2.7 correctly reflects the abstraction of the React Native-specific hook, which is a backward-compatible change.

packages/components/CHANGELOG.md (1)

3-7: Changelog entry accurately documents the change.

The entry clearly explains the abstraction of the React Native-specific hook and the reasoning behind it (preventing web import issues).

packages/components/modules/messages/native/index.ts (1)

1-2: Clean native module entry point.

The barrel export pattern correctly establishes the entry point for native message components and follows standard conventions.

packages/components/modules/messages/native/graphql/subscriptions/useMessagesListSubscription.tsx (1)

8-46: Well-implemented native subscription hook.

The implementation correctly:

  • Uses useFocusEffect for React Native lifecycle management
  • Properly manages subscription cleanup with disposable refs
  • Guards against missing required parameters
  • Uses appropriate memoization for performance
packages/components/modules/messages/common/graphql/subscriptions/useMessagesListSubscription.tsx (1)

1-35: Clean abstraction of web-specific subscription logic.

The removal of React Native-specific code and simplification to use useSubscription correctly separates concerns between web and native implementations.

@vitorguima vitorguima merged commit ba018f5 into master Jul 23, 2025
8 checks passed
@vitorguima vitorguima deleted the hotfix/messages-list-subscription branch July 23, 2025 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants