Enable Offline mode of the SyncService, so that the sync starts automatically when the network is back.

Also rely on the sync state to render the "Offline" banner.
This commit is contained in:
Benoit Marty 2025-02-03 17:47:35 +01:00
parent f4afda119b
commit f84aa03605
20 changed files with 91 additions and 74 deletions

View file

@ -13,8 +13,10 @@ import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
class FakeSyncService(
syncStateFlow: MutableStateFlow<SyncState> = MutableStateFlow(SyncState.Idle)
initialSyncState: SyncState = SyncState.Idle,
) : SyncService {
private val syncStateFlow: MutableStateFlow<SyncState> = MutableStateFlow(initialSyncState)
var startSyncLambda: () -> Result<Unit> = { Result.success(Unit) }
override suspend fun startSync(): Result<Unit> {
return startSyncLambda()
@ -26,4 +28,8 @@ class FakeSyncService(
}
override val syncState: StateFlow<SyncState> = syncStateFlow
suspend fun emitSyncState(syncState: SyncState) {
syncStateFlow.emit(syncState)
}
}