mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-02 03:06:14 +00:00
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:
committed by
GitHub
parent
50aa723f63
commit
9cc5cf9a01
+4
@@ -1024,6 +1024,10 @@ class RustMatrixClient(
|
||||
return RustHomeserverCapabilitiesProvider(innerClient.homeserverCapabilities())
|
||||
}
|
||||
|
||||
override fun totalUnreadCount(): Result<Long> = runCatchingExceptions {
|
||||
innerClient.totalUnreadNotifications().toLong()
|
||||
}
|
||||
|
||||
private fun scheduleBackgroundSearchBackfill() {
|
||||
featureFlagService.isFeatureEnabledFlow(FeatureFlags.MessageSearch)
|
||||
.distinctUntilChanged()
|
||||
|
||||
+10
@@ -12,16 +12,20 @@ import io.element.android.libraries.core.coroutine.mapState
|
||||
import io.element.android.libraries.core.extensions.runCatchingExceptions
|
||||
import io.element.android.libraries.matrix.api.sync.SyncService
|
||||
import io.element.android.libraries.matrix.api.sync.SyncState
|
||||
import io.element.android.libraries.matrix.impl.roomlist.stateFlow
|
||||
import kotlinx.coroutines.CoroutineDispatcher
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.NonCancellable
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.SharingStarted
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import kotlinx.coroutines.flow.distinctUntilChanged
|
||||
import kotlinx.coroutines.flow.filter
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import kotlinx.coroutines.flow.stateIn
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.matrix.rustcomponents.sdk.RoomListServiceState
|
||||
import org.matrix.rustcomponents.sdk.SyncServiceState
|
||||
import timber.log.Timber
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
@@ -78,4 +82,10 @@ class RustSyncService(
|
||||
.stateIn(sessionCoroutineScope, SharingStarted.Eagerly, SyncState.Idle)
|
||||
|
||||
override val isOnline: StateFlow<Boolean> = syncState.mapState { it != SyncState.Offline }
|
||||
|
||||
// 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 }
|
||||
.map {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user