Create extension SyncService.isOnline()
This commit is contained in:
parent
3ffafdd7e7
commit
c8f4268545
8 changed files with 18 additions and 60 deletions
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
package io.element.android.libraries.matrix.api.sync
|
||||
|
||||
import io.element.android.libraries.core.coroutine.mapState
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
|
||||
interface SyncService {
|
||||
|
|
@ -25,3 +26,5 @@ interface SyncService {
|
|||
*/
|
||||
val syncState: StateFlow<SyncState>
|
||||
}
|
||||
|
||||
fun SyncService.isOnline(): StateFlow<Boolean> = syncState.mapState { it != SyncState.Offline }
|
||||
|
|
|
|||
|
|
@ -14,11 +14,3 @@ enum class SyncState {
|
|||
Terminated,
|
||||
Offline,
|
||||
}
|
||||
|
||||
fun SyncState.isConnected() = when (this) {
|
||||
SyncState.Idle,
|
||||
SyncState.Running,
|
||||
SyncState.Error,
|
||||
SyncState.Terminated -> true
|
||||
SyncState.Offline -> false
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue