RoomList: try syncing when network is back and inError state

This commit is contained in:
ganfra
2023-06-23 17:07:27 +02:00
parent 1185dbd276
commit bb4f61fe12
6 changed files with 45 additions and 17 deletions

View File

@@ -114,7 +114,7 @@ class RustMatrixClient constructor(
init {
client.setDelegate(clientDelegate)
syncService.syncState()
syncService.syncState
.onEach { syncState ->
if (syncState == SyncState.Syncing) {
onSlidingSyncUpdate()

View File

@@ -22,6 +22,7 @@ import io.element.android.libraries.matrix.impl.room.roomListStateFlow
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.flow.stateIn
@@ -46,13 +47,10 @@ class RustSyncService(
}
}
override fun syncState(): StateFlow<SyncState> {
return roomListService
override val syncState: StateFlow<SyncState> =
roomListService
.roomListStateFlow()
.map(RoomListState::toSyncState)
.onEach { syncState ->
Timber.d("OnSyncState updated = $syncState")
}
.stateIn(sessionCoroutineScope, SharingStarted.Eagerly, SyncState.Idle)
}
.distinctUntilChanged()
.stateIn(sessionCoroutineScope, SharingStarted.WhileSubscribed(), SyncState.Idle)
}