Repository navigation
Add total unread notification count to home screen - #7891
Conversation
This will be calculated on each sync heartbeat (for now, using the state updates for the room list service).
|
📱 Scan the QR code below to install the build (arm64 only) for this PR. |
Codecov Report❌ Patch coverage is 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. 🚀 New features to boost your workflow:
|
bmarty
left a comment
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Using a delay seems a bit fragile. Couldn't we have a flow from the SDK for totalUnreadCount()? Maybe this is a temporary implementation?
There was a problem hiding this comment.
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 } |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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.
Co-authored-by: Benoit Marty <benoitm@element.io>
|
|
Thanks for the update! |



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
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
Checklist