Skip to content

Conversation

@Jignesh-dimagi
Copy link
Contributor

Technical Summary

https://dimagi.atlassian.net/browse/CCCT-1633

Labels and Review

  • Do we need to enhance the manual QA test coverage ? If yes, the "QA Note" label is set correctly
  • Does the PR introduce any major changes worth communicating ? If yes, the "Release Note" label is set and a "Release Note" is specified in PR description.
  • Risk label is set correctly
  • The set of people pinged as reviewers is appropriate for the level of risk of the change

@coderabbitai
Copy link

coderabbitai bot commented Nov 11, 2025

📝 Walkthrough

Walkthrough

This pull request consolidates notification preference cleanup, refactors navigation drawer visibility control, and modifies messaging item rendering in the drawer. PersonalIdManager now clears notification read preferences when a user is forgotten. BaseDrawerActivity introduces a shouldShowDrawer() extension point and removes the LocalBroadcastManager-based automatic refresh mechanism. BaseDrawerController changes its messaging item rendering logic to always display the item rather than conditionally, with the badge visibility adjusted based on unread count. NotificationPrefs adds a new method to remove stored notification preferences from shared storage.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

  • BaseDrawerActivity.kt: Significant structural changes to drawer initialization and lifecycle management; removal of broadcast receiver pattern and introduction of new extension point requires careful review of drawer display logic and initialization flow
  • BaseDrawerController.kt: Change from conditional to unconditional messaging item rendering alters visibility contract; logic density around badge display and unread count handling needs verification
  • Interaction between changes: Cross-file coordination between drawer visibility control and messaging item display requires reviewing how these components interact together

Possibly related PRs

Suggested labels

QA Note

Suggested reviewers

  • OrangeAndGreen
  • shubham1g5
  • conroy-ricketts

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description check ⚠️ Warning The description is largely incomplete; it only includes a ticket link and review checklist but lacks key sections like Product Description, Safety Story, Automated Test Coverage, and QA Plan required by the template. Add Product Description (user-facing effects), Safety Story (confidence and testing approach), Automated Test Coverage, and QA Plan sections as specified in the repository template.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: fixing the issue where the messaging option is not visible in the side menu after signing in, which aligns with the PR's objective and the changes made to drawer and messaging-related components.
✨ 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 jignesh/fix/ccct-1633

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.

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

🧹 Nitpick comments (1)
app/src/org/commcare/navdrawer/BaseDrawerController.kt (1)

199-214: Cache messaging channels before reuse.

We call ConnectMessagingDatabaseHelper.getMessagingChannels(activity) twice in quick succession. Stashing it in a local val avoids duplicate DB work and makes the intent clearer, especially if the helper ever does more than read memory.

-            val unreadCount =
-                if (ConnectMessagingDatabaseHelper.getMessagingChannels(activity).isNotEmpty()) {
+            val messagingChannels = ConnectMessagingDatabaseHelper.getMessagingChannels(activity)
+            val unreadCount =
+                if (messagingChannels.isNotEmpty()) {
                     ConnectMessagingDatabaseHelper.getUnviewedMessages(activity).size
                 } else {
                     0
                 }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3d234c1 and c88682f.

📒 Files selected for processing (4)
  • app/src/org/commcare/connect/PersonalIdManager.java (2 hunks)
  • app/src/org/commcare/navdrawer/BaseDrawerActivity.kt (6 hunks)
  • app/src/org/commcare/navdrawer/BaseDrawerController.kt (1 hunks)
  • app/src/org/commcare/preferences/NotificationPrefs.kt (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: shubham1g5
Repo: dimagi/commcare-android PR: 0
File: :0-0
Timestamp: 2025-05-08T11:08:18.530Z
Learning: PR #3048 "Phase 4 Connect PR" introduces a substantial feature called "Connect" to the CommCare Android app, which includes messaging, job management, delivery tracking, payment processing, authentication flows, and learning modules. It follows a modern architecture using Navigation Components with three navigation graphs, segregated business logic in Manager classes, and proper database persistence.
Learnt from: Jignesh-dimagi
Repo: dimagi/commcare-android PR: 0
File: :0-0
Timestamp: 2025-05-08T13:40:19.645Z
Learning: PR #3048 introduces a comprehensive messaging system in the Connect feature, implementing secure encryption using AES-GCM for message content, proper channel management with consent flows, and a well-designed UI separation between sent and received messages with real-time notification integration.
Learnt from: OrangeAndGreen
Repo: dimagi/commcare-android PR: 3248
File: app/src/org/commcare/connect/MessageManager.java:0-0
Timestamp: 2025-07-29T14:54:47.940Z
Learning: User OrangeAndGreen organizes messaging-related changes into separate PRs rather than mixing them with other Connect work, which aligns with their preference for handling code issues in separate PRs when they are not directly related to the main changes.
📚 Learning: 2025-05-09T10:57:41.073Z
Learnt from: Jignesh-dimagi
Repo: dimagi/commcare-android PR: 3093
File: app/res/navigation/nav_graph_connect_messaging.xml:41-45
Timestamp: 2025-05-09T10:57:41.073Z
Learning: In the CommCare Android codebase, the navigation graph for Connect messaging (`nav_graph_connect_messaging.xml`) intentionally uses `channel_id` as the argument name in the connectMessageFragment, despite using `channelId` in other parts of the same navigation graph. This naming difference is by design in the refactored code.

Applied to files:

  • app/src/org/commcare/navdrawer/BaseDrawerController.kt
🧬 Code graph analysis (1)
app/src/org/commcare/connect/PersonalIdManager.java (1)
app/src/org/commcare/preferences/NotificationPrefs.kt (1)
  • removeNotificationReadPref (27-31)
⏰ 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). (1)
  • GitHub Check: Lint Code Base
🔇 Additional comments (1)
app/src/org/commcare/navdrawer/BaseDrawerActivity.kt (1)

46-67: Nice drawer setup hook.

The new shouldShowDrawer() gate plus centralized controller wiring makes extending subclasses cleaner and removes the eager broadcast wiring—looks solid.

Comment on lines 27 to 30
fun removeNotificationReadPref(context: Context) {
context
.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE)
.edit { remove(PREF_NAME) }
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Fix preference removal key.

removeNotificationReadPref is removing PREF_NAME, but the stored flag lives under KEY_NOTIFICATION_READ_STATUS. As written, nothing is deleted, so a forgotten user keeps the previous read state and the new account sees stale badge visibility. Update the removal to target the actual key (or clear the file).

     fun removeNotificationReadPref(context: Context) {
         context
             .getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE)
-            .edit { remove(PREF_NAME) }
+            .edit { remove(KEY_NOTIFICATION_READ_STATUS) }
     }

(developer.android.com)

📝 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
fun removeNotificationReadPref(context: Context) {
context
.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE)
.edit { remove(PREF_NAME) }
fun removeNotificationReadPref(context: Context) {
context
.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE)
.edit { remove(KEY_NOTIFICATION_READ_STATUS) }
🤖 Prompt for AI Agents
In app/src/org/commcare/preferences/NotificationPrefs.kt around lines 27-30, the
removeNotificationReadPref function calls remove(PREF_NAME) which deletes the
preferences file key rather than the stored flag; change the removal to
remove(KEY_NOTIFICATION_READ_STATUS) (or call clear() on the editor if you
intend to wipe the file) and commit/apply the edit so the notification-read flag
is actually deleted.

@Jignesh-dimagi Jignesh-dimagi merged commit 3aadca6 into master Nov 11, 2025
8 checks passed
@Jignesh-dimagi Jignesh-dimagi deleted the jignesh/fix/ccct-1633 branch November 11, 2025 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-integration-tests Skip android tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants