Skip to content

Add total unread notification count to home screen - #7891

Merged
jmartinesp merged 3 commits into
developfrom
feat/add-total-unread-count-to-home-bottom-bar
Oct 13, 2026
Merged

jmartinesp merged 3 commits into
developfrom
feat/add-total-unread-count-to-home-bottom-bar

Conversation

@jmartinesp

@jmartinesp jmartinesp commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

Content

This will be calculated on each sync heartbeat (for now, using the state updates for the room list service).

Motivation and context

Part of element-hq/element-meta#3314

Screenshots / GIFs

image

Tests

Launch the app, if there are any unread notifications they should be displayed in the badge of the 'chats' bottom bar icon. Receiving new notifications should increase it, and reading some rooms or marking them as read should decrease it.

Note updating this value depends on on the sync to be running: marking a room as unread or reading it in offline mode won't update the value. This is a limitation of the current implementation.

Tested devices

  • Physical
  • Emulator
  • OS version(s): 15

Checklist

  • I am aware of the etiquette.
  • This PR was made with the help of AI:
    • Yes. In this case, please request a review by Copilot.
    • No.
  • Changes have been tested on an Android device or Android emulator with API 24
  • UI change has been tested on both light and dark themes
  • Accessibility has been taken into account. See https://github.com/element-hq/element-x-android/blob/develop/CONTRIBUTING.md#accessibility
  • Pull request is based on the develop branch
  • Pull request title will be used in the release note, it clearly defines what will change for the user
  • Pull request includes screenshots or videos if containing UI changes
  • You've made a self review of your PR

This will be calculated on each sync heartbeat (for now, using the state updates for the room list service).
@jmartinesp jmartinesp added the PR-Feature For a new feature label Oct 9, 2026
@github-actions

github-actions Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

📱 Scan the QR code below to install the build (arm64 only) for this PR.
QR code
If you can't scan the QR code you can install the build via this link: https://i.diawi.com/9kxobs

@codecov

codecov Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.00000% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.24%. Comparing base (5d498ee) to head (8588202).
⚠️ Report is 16 commits behind head on develop.

Files with missing lines Patch % Lines
.../android/libraries/matrix/impl/RustMatrixClient.kt 0.00% 2 Missing ⚠️
...lement/android/features/home/impl/HomePresenter.kt 50.00% 0 Missing and 1 partial ⚠️
.../io/element/android/features/home/impl/HomeView.kt 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #7891      +/-   ##
===========================================
- Coverage    81.24%   81.24%   -0.01%     
===========================================
  Files         2846     2846              
  Lines        83939    83956      +17     
  Branches     10886    10888       +2     
===========================================
+ Hits         68193    68206      +13     
- Misses       11397    11399       +2     
- Partials      4349     4351       +2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jmartinesp
jmartinesp marked this pull request as ready for review October 13, 2026 07:48
@jmartinesp
jmartinesp requested a review from a team as a code owner October 13, 2026 07:48
@jmartinesp
jmartinesp requested review from bmarty and removed request for a team October 13, 2026 07:48

@bmarty bmarty left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks, tested OK!

Maybe involve product about my remark regarding starting the application with unreachable server: in this case the badge will be hidden.

val totalUnreadCount by produceState(0) {
syncService.heartBeat
// Delay the heartbeat so the SDK has time to update the unread count before we read it.
.debounce(100.milliseconds)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Using a delay seems a bit fragile. Couldn't we have a flow from the SDK for totalUnreadCount()? Maybe this is a temporary implementation?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We definitely should, especially given the issue with offline mode, but it's what's available at the moment, sadly.

// TODO actually use a heartbeat mechanism from the SDK, not simulate it with the room list service
override val heartBeat: Flow<Unit> = inner.roomListService()
.stateFlow()
.filter { it == RoomListServiceState.RUNNING }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just as a reviewer's note: I was confused by stateFlow but this is actually not a StateFlow, so multiple RoomListServiceState.RUNNING will be emitted and the heartBeat is working as expected.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah, the same happened to me when I read stateFlow 😅 . Maybe we should refactor it to be statusFlow.

val coroutineState = rememberCoroutineScope()
val matrixUser by client.userProfile.collectAsState()

val totalUnreadCount by produceState(0) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe initialize with client.totalUnreadCount().getOrDefault(0).toInt() instead of 0?

Else if we start the app without network, the badge will not be shown.

@sonarqubecloud

Copy link
Copy Markdown

@jmartinesp
jmartinesp enabled auto-merge (squash) October 13, 2026 10:37
@jmartinesp
jmartinesp merged commit 9cc5cf9 into develop Oct 13, 2026
31 of 33 checks passed
@jmartinesp
jmartinesp deleted the feat/add-total-unread-count-to-home-bottom-bar branch October 13, 2026 10:58
@bmarty

bmarty commented Oct 14, 2026

Copy link
Copy Markdown
Member

Thanks for the update!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR-Feature For a new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants