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

BA-1964: update unread badge and divider behavior #159

Merged

Conversation

Ronan-Fernandes
Copy link
Contributor

@Ronan-Fernandes Ronan-Fernandes commented Dec 14, 2024

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Introduced a new prop firstUnreadMessageId in the MessagesGroup component to enhance unread message handling.
    • Added logic to track and display the first unread message in the MessagesList component.
  • Bug Fixes

    • Streamlined the ChatRoom component by removing unnecessary state management, improving performance and clarity.
  • Documentation

    • Updated type definitions to include the new firstUnreadMessageId property in the MessagesGroupProps interface.
    • Updated changelog to reflect version 0.0.39 with improvements to unread badge and divider behavior.
    • Updated package version to 0.0.39 in package.json.

Copy link

coderabbitai bot commented Dec 14, 2024

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/ChatRoom/index.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.js'
Require stack:

  • /packages/components/.eslintrc.js
  • /node_modules/.pnpm/@eslint[email protected]/node_modules/@eslint/eslintrc/dist/eslintrc.cjs
  • /node_modules/.pnpm/[email protected]/node_modules/eslint/lib/cli-engine/cli-engine.js
  • /node_modules/.pnpm/[email protected]/node_modules/eslint/lib/eslint/eslint.js
  • /node_modules/.pnpm/[email protected]/node_modules/eslint/lib/eslint/index.js
  • /node_modules/.pnpm/[email protected]/node_modules/eslint/lib/cli.js
  • /node_modules/.pnpm/[email protected]/node_modules/eslint/bin/eslint.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1248:15)
    at Module._load (node:internal/modules/cjs/loader:1074:27)
    at TracingChannel.traceSync (node:diagnostics_channel:315:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:217:24)
    at Module.require (node:internal/modules/cjs/loader:1339: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:1546:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1691:10)
    at Module.load (node:internal/modules/cjs/loader:1317:32)

Walkthrough

The pull request introduces significant changes to the messaging components in the application, particularly the ChatRoom, MessagesList, and MessagesGroup. Key modifications include the removal of hooks related to user profile management and message reading, simplifying the component logic. New props and methods have been added to enhance the handling of unread messages, focusing on rendering efficiency. The changelog and package version have also been updated to reflect these changes.

Changes

File Change Summary
packages/components/modules/messages/ChatRoom/index.tsx Removed useCurrentProfile hook, useReadMessageMutation, and associated state management logic.
packages/components/modules/messages/MessagesList/MessagesGroup/index.tsx Added firstUnreadMessageId prop to control unread messages divider rendering.
packages/components/modules/messages/MessagesList/MessagesGroup/types.ts Added optional firstUnreadMessageId property to MessagesGroupProps interface.
packages/components/modules/messages/MessagesList/index.tsx Introduced firstUnreadMessageId state, added getFirstUnreadMessageId() method, and updated rendering logic.
packages/components/CHANGELOG.md Updated changelog for version 0.0.39, noting improvements to unread badge and divider behavior.
packages/components/package.json Updated version from "0.0.38" to "0.0.39" and modified build/dev scripts to include pnpm relay.
packages/components/modules/messages/graphql/subscriptions/useMessageCountUpdateSubscription.tsx Removed unreadMessagesCount field from the profile object in the subscription's payload.
packages/components/modules/messages/graphql/subscriptions/useMessagesListSubscription.tsx Removed a comment line about future enhancements without affecting functionality.

Possibly related PRs

  • BA-1882: update unread mechanism #146: The changes in this PR involve significant modifications to the ChatRoom component, including the removal of hooks related to message reading, which relates to the PR that updates the unread mechanism.
  • BA-1934 [FE packages] Mark Chat as Unread #158: The changes to the ChatRoom component and the removal of message reading logic are relevant to the new feature introduced in this PR, which allows users to mark chats as unread.

Suggested reviewers

  • pt-tsl

Poem

🐰 Hoppity hop, through messages we leap,
Unread dividers now simpler to keep.
Hooks removed, state streamlined with care,
A rabbit's code dance beyond compare!
Messaging magic, clean and bright 🚀


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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

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: 2

🧹 Outside diff range and nitpick comments (2)
packages/components/modules/messages/ChatRoom/index.tsx (1)

Line range hint 26-26: Consider addressing TODOs before merging.

There are two TODOs that should be addressed:

  1. Pre-loading the query instead of using lazy loading
  2. Handling errors for chatRoom

These could impact the user experience and error handling of the application.

Would you like help implementing these improvements? I can help with:

  1. Converting to preloaded query using QueryLoader
  2. Adding proper error boundaries and error states

Also applies to: 35-35

packages/components/modules/messages/MessagesList/MessagesGroup/index.tsx (1)

Line range hint 60-78: Consider extracting styles and adding i18n support

The new unread messages divider logic is clean and effective. Consider these improvements:

  1. Extract the divider styling to a styled component or theme
  2. Add internationalization support for the "New Messages" text

Example refactor:

+ const UnreadDivider = styled(Divider)(({ theme }) => ({
+   '&.MuiDivider-root::before, &.MuiDivider-root::after': {
+     borderTop: `1px solid ${theme.palette.error.light}`,
+   },
+ }));

  if (currentMessage?.id === firstUnreadMessageId) {
    return (
-     <Divider
-       variant="fullWidth"
-       sx={{
-         '&.MuiDivider-root::before, &.MuiDivider-root::after': {
-           borderTop: `1px solid ${theme.palette.error.light}`,
-         },
-       }}
-     >
+     <UnreadDivider variant="fullWidth">
        <Typography variant="caption" color="error" sx={{ textAlign: 'center' }}>
-         New Messages
+         {t('messages.newMessages')}
        </Typography>
-     </Divider>
+     </UnreadDivider>
    )
  }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 3c2ea87 and 08c441d.

📒 Files selected for processing (4)
  • packages/components/modules/messages/ChatRoom/index.tsx (1 hunks)
  • packages/components/modules/messages/MessagesList/MessagesGroup/index.tsx (3 hunks)
  • packages/components/modules/messages/MessagesList/MessagesGroup/types.ts (1 hunks)
  • packages/components/modules/messages/MessagesList/index.tsx (6 hunks)
🔇 Additional comments (7)
packages/components/modules/messages/MessagesList/MessagesGroup/types.ts (1)

15-15: LGTM! Verify type usage across components.

The optional firstUnreadMessageId type is well-defined. The union type string | null properly handles cases where there might not be any unread messages.

Let's verify the type usage across components:

✅ Verification successful

Type usage is consistent across components

The verification shows proper type consistency:

  • Type definition in types.ts: firstUnreadMessageId?: string | null
  • State declaration in MessagesList/index.tsx: useState<string | null | undefined>(null)
  • Prop passing and usage in both MessagesList and MessagesGroup components
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for firstUnreadMessageId usage to ensure type consistency
ast-grep --pattern 'firstUnreadMessageId?: string | null'
rg 'firstUnreadMessageId'

Length of output: 930

packages/components/modules/messages/ChatRoom/index.tsx (1)

3-3: Good job simplifying the ChatRoom component!

The removal of profile and read status management from this component improves separation of concerns. The component now focuses solely on rendering the chat room interface.

Also applies to: 16-42

packages/components/modules/messages/MessagesList/index.tsx (2)

Line range hint 144-154: Consider adding error handling for virtualization.

The TODO comment about overscan causing stack overflow should be addressed with proper error boundaries.

Let's check for similar virtualization issues:

Consider implementing:

  1. Error boundaries around the virtualized list
  2. Fallback rendering for large datasets
  3. Progressive loading with proper throttling

62-70: 🛠️ Refactor suggestion

Potential race condition in unread message handling.

The effect properly cleans up state, but there's a potential race condition between setting firstUnreadMessageId and the read message mutation.

Let's verify the mutation timing:

Consider combining the effects and ensuring atomic updates:

 useEffect(() => {
   if (room?.unreadMessagesCount !== 0) {
     const firstUnreadMessage = getFirstUnreadMessage()
     setFirstUnreadMessageId(firstUnreadMessage?.id)
+    if (firstUnreadMessage) {
+      commitMutation({
+        variables: {
+          input: {
+            roomId: room?.id as string,
+            profileId: currentProfile?.id as string,
+          },
+        },
+      })
+    }
   }
   return () => {
     setFirstUnreadMessageId(null)
   }
-}, [selectedRoom, currentProfile])
+}, [selectedRoom, currentProfile, room?.unreadMessagesCount])
packages/components/modules/messages/MessagesList/MessagesGroup/index.tsx (3)

26-26: LGTM: Clean prop addition

The firstUnreadMessageId prop is well-integrated and properly typed.


79-79: LGTM: Correct dependency updates

The dependencies array properly reflects the variables used in the callback, including theme colors for proper reactivity.


26-26: Verify unread message handling integration

Let's ensure the unread message handling is consistent across the messaging system.

Also applies to: 60-60

✅ Verification successful

Based on the results, I can now generate the final response as we have sufficient information about the unread message handling integration.

Unread message handling is properly integrated

The firstUnreadMessageId is well-integrated across the messaging system:

  • Properly managed with useState in the parent MessagesList component
  • Correctly passed down as a prop to MessagesGroup
  • Used appropriately in MessagesGroup to render an unread messages divider
  • Type-safe implementation with proper TypeScript interfaces
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check how firstUnreadMessageId is managed in parent components
echo "Checking MessagesList component for firstUnreadMessageId handling:"
rg -A 5 "firstUnreadMessageId" "packages/components/modules/messages/MessagesList"

echo "\nChecking for potential unread message state management:"
ast-grep --pattern 'const [first_unread_message_id, set_first_unread_message_id] = useState<string | null>'

Length of output: 4409

@Ronan-Fernandes Ronan-Fernandes self-assigned this Dec 16, 2024
@Ronan-Fernandes Ronan-Fernandes force-pushed the BA-1964-FE-package-mark-as-read-behavior-change branch from 0fab4c8 to 99922a0 Compare December 16, 2024 17:37
Copy link

changeset-bot bot commented Dec 16, 2024

⚠️ No Changeset found

Latest commit: 51aec0b

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

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: 2

♻️ Duplicate comments (1)
packages/components/modules/messages/MessagesList/index.tsx (1)

50-61: ⚠️ Potential issue

Consider edge cases in getFirstUnreadMessage function.

The function's array access pattern could lead to undefined access issues.

Apply this safer implementation:

 const getFirstUnreadMessageId = () => {
   if (room?.unreadMessagesCount === 0) return null
   return allMessages.find((message, index) => {
-    const previousMessage = allMessages?.[index + 1]
-    const hasPreviousMessage = !!previousMessage
+    const previousMessage = index < allMessages.length - 1 ? allMessages[index + 1] : null
+    const hasPreviousMessage = Boolean(previousMessage)
     return (
       message?.profile?.id !== currentProfile?.id &&
       !message?.isRead &&
       (!hasPreviousMessage || previousMessage?.isRead)
     )
   })?.id
 }
🧹 Nitpick comments (1)
packages/components/modules/messages/ChatRoom/index.tsx (1)

Line range hint 16-45: LGTM: Component successfully simplified to focus on core rendering.

The removal of profile management and message reading logic has effectively streamlined this component. The changes align well with the single responsibility principle, making the code more maintainable.

This refactoring improves the separation of concerns by moving the message read status management to a more appropriate location in the MessagesList component.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 0fab4c8 and 99922a0.

📒 Files selected for processing (6)
  • packages/components/CHANGELOG.md (1 hunks)
  • packages/components/modules/messages/ChatRoom/index.tsx (1 hunks)
  • packages/components/modules/messages/MessagesList/MessagesGroup/index.tsx (3 hunks)
  • packages/components/modules/messages/MessagesList/MessagesGroup/types.ts (1 hunks)
  • packages/components/modules/messages/MessagesList/index.tsx (5 hunks)
  • packages/components/package.json (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
  • packages/components/package.json
  • packages/components/modules/messages/MessagesList/MessagesGroup/types.ts
  • packages/components/CHANGELOG.md
  • packages/components/modules/messages/MessagesList/MessagesGroup/index.tsx
🔇 Additional comments (3)
packages/components/modules/messages/ChatRoom/index.tsx (1)

3-4: LGTM: Simplified imports align with component's focused responsibility.

The removal of unnecessary hooks and the reduction to core React imports better reflects the component's streamlined responsibility of rendering the chat room.

packages/components/modules/messages/MessagesList/index.tsx (2)

46-48: LGTM: Appropriate hooks added for message read status management.

The addition of these hooks aligns with moving the read status management responsibility to this component.


109-111: LGTM: Properly passing firstUnreadMessageId to MessagesGroup.

The integration of the unread message tracking with the MessagesGroup component is implemented correctly.

Comment on lines 65 to 76
useEffect(() => {
if (room?.unreadMessagesCount !== 0) {
commitMutation({
variables: {
input: {
roomId: room?.id as string,
profileId: currentProfile?.id as string,
},
},
})
}
}, [room?.id, room?.unreadMessagesCount, currentProfile])
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Add error handling for the read message mutation.

The mutation commitment lacks error handling which could lead to silent failures.

Consider adding error handling:

 useEffect(() => {
   if (room?.unreadMessagesCount !== 0) {
     commitMutation({
       variables: {
         input: {
           roomId: room?.id as string,
           profileId: currentProfile?.id as string,
         },
       },
+      onError: (error) => {
+        console.error('Failed to mark messages as read:', error);
+        // Consider showing a user-friendly error notification
+      },
     })
   }
 }, [room?.id, room?.unreadMessagesCount, currentProfile])
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
useEffect(() => {
if (room?.unreadMessagesCount !== 0) {
commitMutation({
variables: {
input: {
roomId: room?.id as string,
profileId: currentProfile?.id as string,
},
},
})
}
}, [room?.id, room?.unreadMessagesCount, currentProfile])
useEffect(() => {
if (room?.unreadMessagesCount !== 0) {
commitMutation({
variables: {
input: {
roomId: room?.id as string,
profileId: currentProfile?.id as string,
},
},
onError: (error) => {
console.error('Failed to mark messages as read:', error);
// Consider showing a user-friendly error notification
},
})
}
}, [room?.id, room?.unreadMessagesCount, currentProfile])

})?.id
}

const firstUnreadMessageId = useMemo(getFirstUnreadMessageId, [selectedRoom, currentProfile])
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

Dependencies for firstUnreadMessageId memoization need to be updated

The getFirstUnreadMessageId function uses room, allMessages, and currentProfile internally, but the current memoization only includes selectedRoom and currentProfile. Based on the code analysis:

  • allMessages is derived from room?.allMessages?.edges
  • The function checks room?.unreadMessagesCount
  • It uses message?.profile?.id and message?.isRead from allMessages

The memoization should include:

  • room?.unreadMessagesCount
  • allMessages
🔗 Analysis chain

Verify memoization dependencies for firstUnreadMessageId.

The current dependencies might not capture all relevant state changes.

Also applies to: 121-121


Let me gather more information about the dependencies used in the memoization.


Let me try a different approach to find the dependencies.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for state variables used in getFirstUnreadMessageId
rg -A 2 "const.*State|useState" packages/components/modules/messages/MessagesList/
# Search for variables used in the function
ast-grep --pattern 'const getFirstUnreadMessageId = () => { $$$  }'

Length of output: 1616


Script:

#!/bin/bash
# Search for allMessages and room variables
rg -B 5 "const \{.*allMessages.*\}" packages/components/modules/messages/MessagesList/
rg -B 5 "const \{.*room.*\}" packages/components/modules/messages/MessagesList/

# Search for any updates to these variables
ast-grep --pattern 'setAllMessages($$$)'
ast-grep --pattern 'setRoom($$$)'

Length of output: 249


Script:

#!/bin/bash
# Search for variable declarations and props destructuring
rg -B 2 "const.*=.*props" packages/components/modules/messages/MessagesList/
rg -B 2 "const \{.*\}.*=.*props" packages/components/modules/messages/MessagesList/

# Look for allMessages and room in the component
rg "allMessages|room" packages/components/modules/messages/MessagesList/index.tsx

# Check for any hooks that might update these values
rg "use\w+" packages/components/modules/messages/MessagesList/index.tsx

Length of output: 2482

@anicioalexandre anicioalexandre force-pushed the BA-1964-FE-package-mark-as-read-behavior-change branch from 99922a0 to 51aec0b Compare December 29, 2024 21:50
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

♻️ Duplicate comments (3)
packages/components/modules/messages/MessagesList/index.tsx (3)

50-61: ⚠️ Potential issue

Fix edge cases in getFirstUnreadMessageId function

The function has potential edge cases when accessing array indices.

Apply this safer implementation:

 const getFirstUnreadMessageId = () => {
   if (room?.unreadMessages?.count === 0) return null
   return allMessages.find((message, index) => {
-    const previousMessage = allMessages?.[index + 1]
-    const hasPreviousMessage = !!previousMessage
+    const previousMessage = index < allMessages.length - 1 ? allMessages[index + 1] : null
+    const hasPreviousMessage = Boolean(previousMessage)
     return (
       message?.profile?.id !== currentProfile?.id &&
       !message?.isRead &&
       (!hasPreviousMessage || previousMessage?.isRead)
     )
   })?.id
 }

65-76: ⚠️ Potential issue

Add error handling for read message mutation

The mutation lacks error handling which could lead to silent failures.

Add error handling:

 useEffect(() => {
   if (room?.unreadMessages?.count !== 0) {
     commitMutation({
       variables: {
         input: {
           roomId: room?.id as string,
           profileId: currentProfile?.id as string,
         },
       },
+      onError: (error) => {
+        console.error('Failed to mark messages as read:', error);
+        // Consider showing a user-friendly error notification
+      },
     })
   }
 }, [room?.id, room?.unreadMessages?.count, currentProfile])

63-63: ⚠️ Potential issue

Update dependencies for firstUnreadMessageId memoization

The memoization dependencies are incomplete and should include all values used in the calculation.

The dependencies should include:

  • room?.unreadMessages?.count
  • allMessages
🧹 Nitpick comments (1)
packages/components/modules/messages/MessagesList/MessagesGroup/index.tsx (1)

76-76: Consider memoizing theme.palette.error.light

The theme value could be memoized to prevent unnecessary re-renders.

+ const errorLight = useMemo(() => theme.palette.error.light, [theme.palette.error.light]);
  const renderUnreadMessagesDivider = useCallback(
    (index: number) => {
      // ...
    },
-   [allMessages, firstUnreadMessageId, theme.palette.error.light],
+   [allMessages, firstUnreadMessageId, errorLight],
  )
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 99922a0 and 51aec0b.

📒 Files selected for processing (8)
  • packages/components/CHANGELOG.md (2 hunks)
  • packages/components/modules/messages/ChatRoom/index.tsx (1 hunks)
  • packages/components/modules/messages/MessagesList/MessagesGroup/index.tsx (3 hunks)
  • packages/components/modules/messages/MessagesList/MessagesGroup/types.ts (1 hunks)
  • packages/components/modules/messages/MessagesList/index.tsx (5 hunks)
  • packages/components/modules/messages/graphql/subscriptions/useMessageCountUpdateSubscription.tsx (0 hunks)
  • packages/components/modules/messages/graphql/subscriptions/useMessagesListSubscription.tsx (0 hunks)
  • packages/components/package.json (1 hunks)
💤 Files with no reviewable changes (2)
  • packages/components/modules/messages/graphql/subscriptions/useMessagesListSubscription.tsx
  • packages/components/modules/messages/graphql/subscriptions/useMessageCountUpdateSubscription.tsx
🚧 Files skipped from review as they are similar to previous changes (3)
  • packages/components/modules/messages/MessagesList/MessagesGroup/types.ts
  • packages/components/CHANGELOG.md
  • packages/components/package.json
🔇 Additional comments (4)
packages/components/modules/messages/ChatRoom/index.tsx (2)

Line range hint 26-33: Consider implementing query preloading as noted in TODO comment

The lazy loading of the chat room query could impact initial render performance. Consider implementing query preloading to improve the user experience.

Would you like me to help implement query preloading or create a GitHub issue to track this improvement?


Line range hint 17-54: LGTM! Good separation of concerns

The removal of profile management and message reading logic from this component improves its focus and maintainability. The component now solely handles rendering the chat room UI, which better aligns with the single responsibility principle.

packages/components/modules/messages/MessagesList/index.tsx (1)

Line range hint 141-144: Address TODO comment regarding overscan

The TODO comment indicates a potential stack overflow issue with overscan.

Would you like me to help investigate alternative solutions for implementing virtualization that don't risk stack overflow? We could:

  1. Implement chunked loading
  2. Use a different virtualization strategy
  3. Add proper error boundaries
packages/components/modules/messages/MessagesList/MessagesGroup/index.tsx (1)

Line range hint 57-75: LGTM! Clean implementation of unread messages divider

The new implementation using firstUnreadMessageId simplifies the logic and provides a clear, single source of truth for determining where to show the unread messages divider.

@anicioalexandre anicioalexandre changed the title Update unread badge and divider behavior BA-1964: update unread badge and divider behavior Dec 29, 2024
@anicioalexandre anicioalexandre merged commit 43c6c53 into master Dec 29, 2024
8 of 9 checks passed
@anicioalexandre anicioalexandre deleted the BA-1964-FE-package-mark-as-read-behavior-change branch December 29, 2024 22:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants