Skip to content

Conversation

@tsl-ps2
Copy link
Collaborator

@tsl-ps2 tsl-ps2 commented Mar 21, 2025

Description

As a user, on the BaseApp React Native,I would like to see dividers in my notification list based on how old the notifications are, In order to distinguish between recent and older notifications.

Acceptance Criteria

  • Given I have multiple notifications, when I open the notifications page, then the notifications should be grouped by Read/Unread and separated by a divider.

  • The divider will have the "Read" Label

  • The reverse chronological sort should be maintained inside each group. (Most recent first)

  • Given a notification is mark as read, then it should go to the read group live.

    • This is for the case when we click on "Mark all as read button", where we don't redirect to another page.
  • If everything is read, then the divider should be hidden.

Approvd
https://app.approvd.io/silverlogic/BA/stories/38686

Summary by CodeRabbit

  • New Features
    • Introduced a visual divider in the notifications list to enhance readability.
    • Enabled an automatic refresh for notifications after marking them as read.
    • Optimized the notifications fetching strategy for a smoother and more responsive experience.
    • Added a new Divider component to improve layout structure within the notifications list.
  • Bug Fixes
    • Improved organization of notifications by categorizing them into unread and read sections.

@coderabbitai
Copy link

coderabbitai bot commented Mar 21, 2025

Walkthrough

The changes introduce a new functional component named Divider for the notifications list, along with associated styling in a new styles.ts file. The NotificationItem component has been updated to accept a new refetch prop, which is used to refresh data after marking a notification as read. Additionally, the NotificationsList component's rendering logic has been modified to conditionally display the Divider based on the read status of notifications, and the fetch policy for notifications has been updated.

Changes

File(s) Change Summary
packages/components/modules/notifications/native/NotificationsList/Divider/index.tsx
packages/components/modules/notifications/native/NotificationsList/Divider/styles.ts
Added new Divider component and its styling using theme-provided styles.
packages/components/modules/notifications/native/NotificationsList/NotificationItem/index.tsx
packages/components/modules/notifications/native/NotificationsList/NotificationItem/types.ts
Introduced a new refetch prop (of type VoidFunction) to the NotificationItem, updating its mutation callback to trigger a data refresh.
packages/components/modules/notifications/native/NotificationsList/index.tsx Updated notification list logic by modifying the refetchNotifications fetch policy and updating the renderNotificationItem function to conditionally render the Divider between notifications based on their read status.
packages/components/CHANGELOG.md Added version 1.0.30 to the changelog, detailing changes related to notification management.
packages/components/package.json Updated version number from 1.0.29 to 1.0.30.

Possibly related PRs

  • BA-1964: update unread badge and divider behavior #159: The changes in the main PR, which introduce a new Divider component for visually separating notifications, are related to the modifications in the retrieved PR that also involve updating the behavior of dividers for unread messages in the MessagesGroup component. Both PRs focus on enhancing the visual representation of notifications/messages based on their read/unread status.

Suggested labels

needs changes

Suggested reviewers

  • Ronan-Fernandes
  • anicioalexandre
  • deboracosilveira
  • pt-tsl

Poem

I’m a hopping rabbit, quick on my feet,
In the code garden where changes meet.
New dividers line up, so neat and clear,
Refetching tales now are dear.
With bytes and bops, we cheer with glee,
A magical update from CodeRabbit Inc.!
🐰✨

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/notifications/native/NotificationsList/NotificationItem/types.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: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)
packages/components/modules/notifications/native/NotificationsList/Divider/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-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: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)
packages/components/modules/notifications/native/NotificationsList/Divider/styles.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: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)
  • 2 others

📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 8502d96 and 4b92372.

📒 Files selected for processing (7)
  • packages/components/CHANGELOG.md (1 hunks)
  • packages/components/modules/notifications/native/NotificationsList/Divider/index.tsx (1 hunks)
  • packages/components/modules/notifications/native/NotificationsList/Divider/styles.ts (1 hunks)
  • packages/components/modules/notifications/native/NotificationsList/NotificationItem/index.tsx (2 hunks)
  • packages/components/modules/notifications/native/NotificationsList/NotificationItem/types.ts (1 hunks)
  • packages/components/modules/notifications/native/NotificationsList/index.tsx (3 hunks)
  • packages/components/package.json (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (7)
  • packages/components/CHANGELOG.md
  • packages/components/modules/notifications/native/NotificationsList/NotificationItem/index.tsx
  • packages/components/package.json
  • packages/components/modules/notifications/native/NotificationsList/Divider/index.tsx
  • packages/components/modules/notifications/native/NotificationsList/NotificationItem/types.ts
  • packages/components/modules/notifications/native/NotificationsList/Divider/styles.ts
  • packages/components/modules/notifications/native/NotificationsList/index.tsx
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Component Test Packages

🪧 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.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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: 0

🧹 Nitpick comments (2)
packages/components/modules/notifications/native/NotificationsList/Divider/index.tsx (1)

16-18: Consider adding accessibility support to the divider text.

For better accessibility, consider adding appropriate accessibility props to the Text component to ensure screen readers can properly announce the divider.

<View>
-  <Text variant="caption">Read</Text>
+  <Text variant="caption" accessibilityRole="header" accessibilityLabel="Read notifications section">Read</Text>
</View>
packages/components/modules/notifications/native/NotificationsList/index.tsx (1)

55-73: Logic for displaying dividers between read and unread notifications is well implemented.

The code now correctly checks if the current notification is read and the previous one is unread to determine when to show the divider. The React Fragment is appropriately used to render multiple elements.

However, there's still a TODO comment on line 61 that seems redundant given that you've now implemented the divider functionality.

- // TODO add notifications divider and unread/Read notifications as per design
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between c851380 and 563c4ba.

📒 Files selected for processing (5)
  • packages/components/modules/notifications/native/NotificationsList/Divider/index.tsx (1 hunks)
  • packages/components/modules/notifications/native/NotificationsList/Divider/styles.ts (1 hunks)
  • packages/components/modules/notifications/native/NotificationsList/NotificationItem/index.tsx (2 hunks)
  • packages/components/modules/notifications/native/NotificationsList/NotificationItem/types.ts (1 hunks)
  • packages/components/modules/notifications/native/NotificationsList/index.tsx (3 hunks)
🧰 Additional context used
🧬 Code Definitions (2)
packages/components/modules/notifications/native/NotificationsList/Divider/index.tsx (1)
packages/components/modules/notifications/native/NotificationsList/Divider/styles.ts (1) (1)
  • createStyles (5-25)
packages/components/modules/notifications/native/NotificationsList/index.tsx (1)
packages/components/modules/notifications/native/NotificationsList/NotificationItem/types.ts (1) (1)
  • NotificationItemProps (9-13)
🔇 Additional comments (9)
packages/components/modules/notifications/native/NotificationsList/NotificationItem/types.ts (1)

12-12: Appropriate addition of refetch callback to support dynamic updates.

Adding the refetch property to the NotificationItemProps interface enables the component to trigger data refreshes when a notification is marked as read, which aligns with the requirement to dynamically move notifications between read/unread groups without page redirects.

packages/components/modules/notifications/native/NotificationsList/Divider/styles.ts (1)

1-25: Well-structured and flexible styling for the divider component.

The styles are defined using a function that accepts a theme parameter, which promotes consistent theming across the application. The layout uses flexbox appropriately to create a horizontal divider with text in the center.

packages/components/modules/notifications/native/NotificationsList/NotificationItem/index.tsx (1)

13-13: Good implementation of the refetch callback.

The component now correctly accepts the refetch prop and uses it in the onCompleted callback of the mutation to refresh the notification list after marking a notification as read. This enables the UI to update dynamically when notifications change status.

Also applies to: 22-22

packages/components/modules/notifications/native/NotificationsList/Divider/index.tsx (1)

1-24: Clean implementation of the "Read" divider component.

The divider component is implemented as a simple, reusable component that creates a visual separator with text. It follows best practices by using the theme provider for consistent styling and separating styles into their own file.

packages/components/modules/notifications/native/NotificationsList/index.tsx (5)

18-18: Import of the Divider component looks good.

This import is necessary for the new feature that divides notifications into read and unread sections.


52-52: Change in fetch policy may improve UI responsiveness.

Changing from 'network-only' to 'store-and-network' will allow the component to display cached data immediately while fetching fresh data in the background. This should provide a better user experience by reducing perceived loading times.


80-83: FlatList update properly passes index parameter.

The update to pass both item and index to renderNotificationItem is necessary for the divider logic to work correctly.


65-70: NotificationItem now receives refetch callback for dynamic updates.

Adding the refetch prop allows notifications to be dynamically moved to the read group when marked as read, satisfying the requirement to update the list without page redirects.


57-60: Consider adding a test for the edge case of all read notifications.

The current implementation will correctly hide the divider when all notifications are marked as read (since there won't be a transition from unread to read). However, it might be worth adding a test to explicitly verify this behavior.

Can you verify that when all notifications are marked as read, the divider is not displayed in any scenario?

@anicioalexandre anicioalexandre added needs changes PR was reviewed, and changes are required. needs review PR needs to be reviewed. and removed needs changes PR was reviewed, and changes are required. labels Mar 26, 2025
@tsl-ps2 tsl-ps2 force-pushed the BA-2392-divider-package branch from 563c4ba to a566e9d Compare April 1, 2025 21:19
@changeset-bot
Copy link

changeset-bot bot commented Apr 1, 2025

⚠️ No Changeset found

Latest commit: 4b92372

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

🧹 Nitpick comments (1)
packages/components/CHANGELOG.md (1)

7-7: Notification Divider Feature Entry

The bullet point - Native: Dividing notifications into unread/read accurately reflects the new functionality for organizing notifications. Consider, if appropriate, adding a brief note regarding the dynamic behavior (e.g., auto-updating when notifications are marked as read) or the reverse chronological sorting to provide more context for users reviewing the changelog.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between a566e9d and 8502d96.

📒 Files selected for processing (3)
  • packages/components/CHANGELOG.md (1 hunks)
  • packages/components/modules/notifications/native/NotificationsList/NotificationItem/index.tsx (2 hunks)
  • packages/components/package.json (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • packages/components/package.json
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/components/modules/notifications/native/NotificationsList/NotificationItem/index.tsx
🔇 Additional comments (2)
packages/components/CHANGELOG.md (2)

3-4: Ensure Consistent Version Formatting

The new release version 1.0.29 is clearly added and follows the expected changelog structure. Verify that this bump aligns with your semantic versioning guidelines.


5-6: Changelog Section Header is Consistent

The "### Patch Changes" header is formatted consistently with previous entries. This ensures clarity in the type of update being released.

@tsl-ps2 tsl-ps2 added approved Review is done, and PR is approved, ready to merge. and removed needs review PR needs to be reviewed. labels Apr 2, 2025
@tsl-ps2 tsl-ps2 force-pushed the BA-2392-divider-package branch from 8502d96 to 4b92372 Compare April 2, 2025 13:11
@sonarqubecloud
Copy link

sonarqubecloud bot commented Apr 2, 2025

@tsl-ps2 tsl-ps2 merged commit be8864a into master Apr 2, 2025
7 of 8 checks passed
@nossila nossila deleted the BA-2392-divider-package branch May 26, 2025 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Review is done, and PR is approved, ready to merge.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants