Skip to content

Commit adde9b1

Browse files
authored
Merge pull request #131 from YAPP-Github/fix/#130-routine-edit
[Fix/#130] 루틴 수정 시 수정된 루틴 데이터를 fetch 하도록 수정합니다.
2 parents 1765425 + 49ebab2 commit adde9b1

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

presentation/src/main/java/com/threegap/bitnagil/presentation/routinelist/RoutineListViewModel.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import androidx.lifecycle.viewModelScope
66
import com.threegap.bitnagil.domain.routine.usecase.DeleteRoutineForDayUseCase
77
import com.threegap.bitnagil.domain.routine.usecase.DeleteRoutineUseCase
88
import com.threegap.bitnagil.domain.routine.usecase.FetchWeeklyRoutinesUseCase
9+
import com.threegap.bitnagil.domain.writeroutine.usecase.GetWriteRoutineEventFlowUseCase
910
import com.threegap.bitnagil.presentation.common.mviviewmodel.MviViewModel
1011
import com.threegap.bitnagil.presentation.home.util.getCurrentWeekDays
1112
import com.threegap.bitnagil.presentation.routinelist.model.RoutineListIntent
@@ -24,6 +25,7 @@ class RoutineListViewModel @Inject constructor(
2425
private val fetchWeeklyRoutinesUseCase: FetchWeeklyRoutinesUseCase,
2526
private val deleteRoutineUseCase: DeleteRoutineUseCase,
2627
private val deleteRoutineForDayUseCase: DeleteRoutineForDayUseCase,
28+
private val getWriteRoutineEventFlowUseCase: GetWriteRoutineEventFlowUseCase,
2729
) : MviViewModel<RoutineListState, RoutineListSideEffect, RoutineListIntent>(
2830
savedStateHandle = savedStateHandle,
2931
initState = RoutineListState(
@@ -38,6 +40,7 @@ class RoutineListViewModel @Inject constructor(
3840

3941
init {
4042
fetchRoutines()
43+
observeRoutineChanges()
4144
}
4245

4346
override suspend fun SimpleSyntax<RoutineListState, RoutineListSideEffect>.reduceState(
@@ -114,6 +117,14 @@ class RoutineListViewModel @Inject constructor(
114117
return newState
115118
}
116119

120+
private fun observeRoutineChanges() {
121+
viewModelScope.launch {
122+
getWriteRoutineEventFlowUseCase().collect {
123+
fetchRoutines()
124+
}
125+
}
126+
}
127+
117128
private fun fetchRoutines() {
118129
sendIntent(RoutineListIntent.UpdateLoading(true))
119130
val currentWeek = stateFlow.value.selectedDate.getCurrentWeekDays()

0 commit comments

Comments
 (0)