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
- Open the app with at least one unread notification (badge visible on the bell icon)
- Tap the bell to open the notifications list
- Tap one or more notifications (each opens its linked URL)
- Return to the Contributions screen
- 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()`:
-
`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.
-
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.
-
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)
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
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()`:
`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.
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.
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
Device name
Pixel 6
Android version
Android 16
Commons app version
6.6.0-beta (debug build)