Skip to content

Add unread count to the room unread indicator#6887

Open
bxdxnn wants to merge 2 commits into
element-hq:developfrom
bxdxnn:feat/unread-count
Open

Add unread count to the room unread indicator#6887
bxdxnn wants to merge 2 commits into
element-hq:developfrom
bxdxnn:feat/unread-count

Conversation

@bxdxnn
Copy link
Copy Markdown
Contributor

@bxdxnn bxdxnn commented May 26, 2026

Content

Add unread count to the room unread indicator in the room list.

The indicator will expand a bit depending on the number of characters. If the count is more than 99, "99+" will be shown instead.

Motivation and context

Fixes #6867 and the duplicate issues of it

Feature parity with Element Classic and it has been frequently requested.

Screenshots / GIFs

Tests

  • Go to the room list

Tested devices

  • Physical
  • Emulator
  • OS version(s):

Checklist

  • 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

@bxdxnn bxdxnn requested a review from a team as a code owner May 26, 2026 15:56
@bxdxnn bxdxnn requested review from bmarty and removed request for a team May 26, 2026 15:56
@github-actions
Copy link
Copy Markdown
Contributor

Thank you for your contribution! Here are a few things to check in the PR to ensure it's reviewed as quickly as possible:

  • If your pull request adds a feature or modifies the UI, this should have an equivalent pull request in the Element X iOS repo unless it only affects an Android-only behaviour or is behind a disabled feature flag, since we need parity in both clients to consider a feature done. It will also need to be approved by our product and design teams before being merged, so it's usually a good idea to discuss the changes in a Github issue first and then start working on them once the approach has been validated.
  • Your branch should be based on origin/develop, at least when it was created.
  • The title of the PR will be used for release notes, so it needs to describe the change visible to the user.
  • The test pass locally running ./gradlew test.
  • The code quality check suite pass locally running ./gradlew runQualityChecks.
  • If you modified anything related to the UI, including previews, you'll have to run the Record screenshots GH action in your forked repo: that will generate compatible new screenshots. However, given Github Actions limitations, it will prevent the CI from running temporarily, until you upload a new commit after that one. To do so, just pull the latest changes and push an empty commit.

@github-actions github-actions Bot added the Z-Community-PR Issue is solved by a community member's PR label May 26, 2026
@jmartinesp
Copy link
Copy Markdown
Member

I'm not the reviewer of this PR, but I don't think we want to include this change at the moment:

With the sync logic used in Element Android classic, you loaded everything that was pending since the last time you synced, and that was quite slow, but it resulted in accurate up to date data.

In Element X on the other hand, we have sliding sync, that only returns the latest N events in a room depending on how it's set up (events, not messages), which is way faster... but can be problematic if we want to display accurate values like the unread count. So it could be easy that you see a room with maybe 5 unread notifications and you open it and there were 50 or 100, because the previous one happened a long time ago and we didn't load the data needed.

We're working on back paginating the rooms in background to make the unread counts more accurate, but that's not ready yet.

By the way, if you wanted to display a number in the indicators you can't just use numberOfUnreadMessages: that's what we'd want to display (maybe?) if the room didn't have notifications enabled. If it had, we'd want to use numberOfUnreadNotifications if I'm not mistaken.

Copy link
Copy Markdown
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

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

Thanks. As you said, this change will require a product decision.

CC @mxandreas

@bxdxnn
Copy link
Copy Markdown
Contributor Author

bxdxnn commented May 27, 2026

@jmartinesp I agree with you, this change felt "good enough" but of course it would not work correctly ATM, it seems like we can just set it behind a feature flag for now?

@bxdxnn bxdxnn force-pushed the feat/unread-count branch from 0ccfbe2 to c73cd68 Compare May 27, 2026 15:51
@sasan7071-maker
Copy link
Copy Markdown

As the person who reported this issue, I think you should enable the unread count even if it's not 100% accurate. It would still be very useful and would solve most of the problem for us. We can always improve the accuracy later.

Copy link
Copy Markdown
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

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

Thanks for the update! I guess it's OK now with the feature flag.

.background(if (isVisible) color else Color.Transparent),
contentAlignment = Alignment.Center,
) {
if (count != null && count > 1) {
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.

Why not "count >= 1"?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That's up to product/design decision, but IMO, to make it less noisy, I think having the indicator without a number would make it clear that there's only one unread message, otherwise there will be a lot of numbers in the room list.

But if this is not wanted, we can make it count > 0 instead.

@sasan7071-maker
Copy link
Copy Markdown

I'm just a user, not a developer. Can you share an APK for Samsung A55 with this feature enabled temporarily, so I can use it until the full fix is ready?

@bxdxnn
Copy link
Copy Markdown
Contributor Author

bxdxnn commented May 29, 2026

@sasan7071-maker this kind of behavior (duplicating issues, flooding PRs with unrelated comments) is not very appropriate and may result in you being blocked from engaging in this repo.

If you need customer support and want your issues to be prioritized, please buy the Element Enterprise solution to get proper support for your problems in the app. I'm just a volunteer doing this work for free.

The APK build is here, you would need to enable the feature flag in the developer options (tap 7 times on the app version) afterwards.

@sasan7071-maker
Copy link
Copy Markdown

I have downloaded and used this, and it worked very well — very useful.
If I were you, this should be moved to the next pre-release and main release.
It was excellent for my needs.
Please consider including it in the next version.
Thank you.

@sasan7071-maker
Copy link
Copy Markdown

I downloaded the APK build is here. it worked very well — very useful.
I think you should enable the "unread count" feature flag in the developer options for the next pre-release and release. I'm waiting for this useful feature.
This feature is not just useful, it is vital for us. We look forward to seeing it enabled in the developer options.

@mxandreas
Copy link
Copy Markdown
Member

Indeed the eventual goal is to show the number of messages (so it is also compatible with Web) however, we have postponed this until we get a reliable number. The work to build the foundation for getting a reliable number is currently in progress.

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

Labels

Z-Community-PR Issue is solved by a community member's PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Show unread message count instead of green dot in ElementX rooms

6 participants