@@ -19,6 +19,8 @@ import kotlinx.coroutines.SupervisorJob
1919import kotlinx.coroutines.channels.BufferOverflow
2020import kotlinx.coroutines.flow.Flow
2121import kotlinx.coroutines.flow.MutableSharedFlow
22+ import kotlinx.coroutines.flow.SharedFlow
23+ import kotlinx.coroutines.flow.asSharedFlow
2224import kotlinx.coroutines.flow.debounce
2325import kotlinx.coroutines.flow.emitAll
2426import kotlinx.coroutines.flow.filterNotNull
@@ -41,6 +43,8 @@ class RoutineRepositoryImpl @Inject constructor(
4143 private val mutex = Mutex ()
4244 private val pendingChangesByDate = mutableMapOf<String , MutableMap <String , RoutineCompletionInfo >>()
4345 private val originalStatesByDate = mutableMapOf<String , MutableMap <String , RoutineCompletionInfo >>()
46+ private val _syncError = MutableSharedFlow <Unit >(extraBufferCapacity = 1 , onBufferOverflow = BufferOverflow .DROP_OLDEST )
47+ override val syncError: SharedFlow <Unit > = _syncError .asSharedFlow()
4448 private val syncTrigger = MutableSharedFlow <Unit >(
4549 extraBufferCapacity = 1 ,
4650 onBufferOverflow = BufferOverflow .DROP_OLDEST ,
@@ -105,6 +109,7 @@ class RoutineRepositoryImpl @Inject constructor(
105109 val syncRequest = RoutineCompletionInfos (routineCompletionInfos = actualChanges.values.toList())
106110 routineRemoteDataSource.syncRoutineCompletion(syncRequest.toDto())
107111 .onFailure {
112+ _syncError .emit(Unit )
108113 val range = routineLocalDataSource.lastFetchRange ? : return @onFailure
109114 fetchAndSave(range.first, range.second)
110115 }
0 commit comments