Skip to content

fix(Android): remove notification from collection when notification is clicked#6955

Open
Rohit3523 wants to merge 4 commits intodevelopfrom
duplicate-notification-fix
Open

fix(Android): remove notification from collection when notification is clicked#6955
Rohit3523 wants to merge 4 commits intodevelopfrom
duplicate-notification-fix

Conversation

@Rohit3523
Copy link
Contributor

@Rohit3523 Rohit3523 commented Jan 29, 2026

Proposed changes

Notifications are stored in a collection. When a notification was clicked, its data was not removed, causing old messages to appear again. This PR clears the notification by ID to prevent stacking.

Issue(s)

https://rocketchat.atlassian.net/browse/CORE-1769

How to test or reproduce

  1. Using Account 2, send a message ("Test-1") to Account 1 and wait for the push notification.
  2. Tap the notification and wait for the app to fully load.
  3. Move the app to the background.
  4. Send another message ("Test-2") from Account 2 to Account 1.
  • Expected: Only "Test-2" should appear in the notification.

  • Actual: Both "Test-1" and "Test-2" appear in the notification.

Screenshots

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • Improvement (non-breaking change which improves a current function)
  • New feature (non-breaking change which adds functionality)
  • Documentation update (if none of the other choices apply)

Checklist

  • I have read the CONTRIBUTING doc
  • I have signed the CLA
  • Lint and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works (if applicable)
  • I have added necessary documentation (if applicable)
  • Any dependent changes have been merged and published in downstream modules

Further comments

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced notification processing to properly clear previous messages, improving notification stack management and preventing duplicate or stale notifications from persisting.

✏️ Tip: You can customize this high-level summary in your review settings.

@Rohit3523 Rohit3523 marked this pull request as ready for review January 29, 2026 19:15
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 29, 2026

Walkthrough

Adds notification clearing logic to NotificationIntentHandler by retrieving the notId from intent extras, parsing it as an integer, and calling CustomPushNotification.clearMessages to remove previous messages before processing the new notification. This executes before serializing notification data for React Native delivery.

Changes

Cohort / File(s) Summary
Notification Clearing Logic
android/app/src/main/java/chat/rocket/reactnative/notification/NotificationIntentHandler.kt
Adds retrieval of notId from intent extras and calls CustomPushNotification.clearMessages(notIdInt) to clear associated messages before processing new notifications. Includes nested try-catch with logging for error handling.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Suggested reviewers

  • OtavioStasiak

Poem

🐰 A tidy warren, notifications cleared,
No phantom guests where none appeared,
Fresh messages bloom, the old ones fade,
Double-stacking ghosts have been betrayed!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: removing notifications from a collection when clicked, which directly addresses the core issue of duplicate notifications.
Linked Issues check ✅ Passed The code change directly implements the fix for CORE-1769 by clearing messages from the notification collection when a notification is clicked, preventing old messages from reappearing.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing the notification duplication issue described in CORE-1769; no unrelated modifications are present.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch duplicate-notification-fix

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (2)
  • TEST-1: Request failed with status code 404
  • TEST-2: Request failed with status code 404

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@Rohit3523
Copy link
Contributor Author

@coderabbitai review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 29, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@Rohit3523 Rohit3523 requested a review from diegolmello January 29, 2026 21:26
@Rohit3523 Rohit3523 requested a deployment to approve_e2e_testing February 4, 2026 17:51 — with GitHub Actions Waiting
@Rohit3523 Rohit3523 requested a deployment to experimental_android_build February 4, 2026 17:54 — with GitHub Actions Waiting
@Rohit3523 Rohit3523 requested a deployment to official_android_build February 4, 2026 17:54 — with GitHub Actions Waiting
@Rohit3523 Rohit3523 requested a deployment to experimental_ios_build February 4, 2026 17:54 — with GitHub Actions Waiting
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.

2 participants