@@ -5,6 +5,7 @@ import androidx.lifecycle.ViewModel
55import com.threegap.bitnagil.domain.emotion.usecase.ObserveDailyEmotionUseCase
66import com.threegap.bitnagil.domain.routine.model.ToggleStrategy
77import com.threegap.bitnagil.domain.routine.usecase.ApplyRoutineToggleUseCase
8+ import com.threegap.bitnagil.domain.routine.usecase.ObserveRoutineSyncErrorUseCase
89import com.threegap.bitnagil.domain.routine.usecase.ObserveWeeklyRoutinesUseCase
910import com.threegap.bitnagil.domain.user.usecase.ObserveUserProfileUseCase
1011import com.threegap.bitnagil.presentation.screen.home.contract.HomeSideEffect
@@ -31,6 +32,7 @@ class HomeViewModel @Inject constructor(
3132 private val observeUserProfileUseCase : ObserveUserProfileUseCase ,
3233 private val observeDailyEmotionUseCase : ObserveDailyEmotionUseCase ,
3334 private val applyRoutineToggleUseCase : ApplyRoutineToggleUseCase ,
35+ private val observeRoutineSyncErrorUseCase : ObserveRoutineSyncErrorUseCase ,
3436) : ContainerHost<HomeState, HomeSideEffect>, ViewModel() {
3537
3638 override val container: Container <HomeState , HomeSideEffect > =
@@ -41,6 +43,7 @@ class HomeViewModel @Inject constructor(
4143 observeDailyEmotion()
4244 observeUserProfile()
4345 observeWeeklyRoutines()
46+ observeRoutineSyncError()
4447 },
4548 )
4649
@@ -87,6 +90,22 @@ class HomeViewModel @Inject constructor(
8790 }
8891 }
8992
93+ private fun observeRoutineSyncError () {
94+ intent {
95+ repeatOnSubscription {
96+ observeRoutineSyncErrorUseCase().collect {
97+ reduce { state.copy(showSyncErrorDialog = true ) }
98+ }
99+ }
100+ }
101+ }
102+
103+ fun dismissSyncErrorDialog () {
104+ intent {
105+ reduce { state.copy(showSyncErrorDialog = false ) }
106+ }
107+ }
108+
90109 fun selectDate (date : LocalDate ) {
91110 intent {
92111 reduce { state.copy(selectedDate = date) }
0 commit comments