Add total unread notification count to home screen (#7891)

* Add total unread notification count to home screen

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

* Simplify `counter` parameter logic

* Read the total unread count when the home screen is first displayed

---------

Co-authored-by: Benoit Marty <benoitm@element.io>
This commit is contained in:
Jorge Martin Espinosa
2026-10-13 12:58:07 +02:00
committed by GitHub
parent 50aa723f63
commit 9cc5cf9a01
13 changed files with 121 additions and 14 deletions
@@ -102,6 +102,7 @@ class FakeMatrixClient(
override val mediaPreviewService: MediaPreviewService = FakeMediaPreviewService(),
override val roomMembershipObserver: RoomMembershipObserver = RoomMembershipObserver(),
private val homeserverCapabilitiesProvider: FakeHomeserverCapabilitiesProvider = FakeHomeserverCapabilitiesProvider(),
private val totalUnreadCountResult: () -> Result<Long> = { Result.success(0L) },
private val accountManagementUrlResult: (AccountManagementAction?) -> Result<String?> = { lambdaError() },
private val resolveRoomAliasResult: suspend (RoomAlias) -> Result<Optional<ResolvedRoomAlias>> = {
Result.success(
@@ -468,4 +469,8 @@ class FakeMatrixClient(
override fun homeserverCapabilities(): HomeserverCapabilitiesProvider {
return homeserverCapabilitiesProvider
}
override fun totalUnreadCount(): Result<Long> {
return totalUnreadCountResult()
}
}
@@ -11,6 +11,8 @@ package io.element.android.libraries.matrix.test.sync
import io.element.android.libraries.core.coroutine.mapState
import io.element.android.libraries.matrix.api.sync.SyncService
import io.element.android.libraries.matrix.api.sync.SyncState
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
@@ -33,6 +35,14 @@ class FakeSyncService(
override val isOnline: StateFlow<Boolean> = syncState.mapState { it != SyncState.Offline }
private val heartBeatFlow = MutableSharedFlow<Unit>(extraBufferCapacity = 1)
override val heartBeat: Flow<Unit> = heartBeatFlow
suspend fun emitHeartBeat() {
heartBeatFlow.emit(Unit)
}
suspend fun emitSyncState(syncState: SyncState) {
syncStateFlow.emit(syncState)
}