Skip to content

[Bug]: In-app notification badge never clears after marking notifications as read #6895

Description

@chrisdebian

Summary

The notification count badge on the Contributions screen never clears, even after tapping notifications to mark them as read. The badge count persists across sessions and app restarts.

Steps to reproduce

  1. Open the app with at least one unread notification (badge visible on the bell icon)
  2. Tap the bell to open the notifications list
  3. Tap one or more notifications (each opens its linked URL)
  4. Return to the Contributions screen
  5. Observe the badge count — it is unchanged

Expected behaviour

After tapping a notification (which calls `markAsRead`), the badge count should decrease. Once all notifications are read, the badge should disappear.

Actual behaviour

The badge count does not decrease. Notifications appear permanently unread. The "Notification marked as read" snackbar (shown on success in `NotificationActivity`) never appears.

Root cause (from code inspection)

In `NotificationActivity.removeNotification()`:

  1. `markNotificationAsRead()` in `NotificationClient` calls `csrfTokenClient.getTokenBlocking()` before sending the API request. If token acquisition fails for any reason (expired session, network issue), it catches the exception and returns `Observable.just(false)` — with no user-facing error.

  2. The `false` result causes the notification to remain in the local list and on the server. When the user returns to `ContributionsFragment`, `setNotificationCount()` re-fetches from the server and shows the same count.

  3. The disposable from the `subscribe()` call in `removeNotification()` is not added to a `CompositeDisposable` (suppressed with `@SuppressLint("CheckResult")`), risking a lost result if the Activity is paused mid-call.

Fix sketch

  • Add user-visible error feedback in the `else` branch of `removeNotification()` (currently silently ignores failure)
  • Track the disposable in a `CompositeDisposable` and dispose on `onDestroy`
  • Consider whether CSRF token failure should trigger a re-login prompt

Device name

Pixel 6

Android version

Android 16

Commons app version

6.6.0-beta (debug build)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions