From 49ebab2b2489cb43832e6dc86f47eb1a8218720c Mon Sep 17 00:00:00 2001 From: wjdrjs00 Date: Sat, 4 Oct 2025 02:44:32 +0900 Subject: [PATCH] =?UTF-8?q?Feat:=20=EB=A3=A8=ED=8B=B4=20=EB=B3=80=EA=B2=BD?= =?UTF-8?q?=20=EC=97=AC=EB=B6=80=20=EA=B4=80=EC=B0=B0=20=EB=A1=9C=EC=A7=81?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/routinelist/RoutineListViewModel.kt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/presentation/src/main/java/com/threegap/bitnagil/presentation/routinelist/RoutineListViewModel.kt b/presentation/src/main/java/com/threegap/bitnagil/presentation/routinelist/RoutineListViewModel.kt index e61e2e57..367317c3 100644 --- a/presentation/src/main/java/com/threegap/bitnagil/presentation/routinelist/RoutineListViewModel.kt +++ b/presentation/src/main/java/com/threegap/bitnagil/presentation/routinelist/RoutineListViewModel.kt @@ -6,6 +6,7 @@ import androidx.lifecycle.viewModelScope import com.threegap.bitnagil.domain.routine.usecase.DeleteRoutineForDayUseCase import com.threegap.bitnagil.domain.routine.usecase.DeleteRoutineUseCase import com.threegap.bitnagil.domain.routine.usecase.FetchWeeklyRoutinesUseCase +import com.threegap.bitnagil.domain.writeroutine.usecase.GetWriteRoutineEventFlowUseCase import com.threegap.bitnagil.presentation.common.mviviewmodel.MviViewModel import com.threegap.bitnagil.presentation.home.util.getCurrentWeekDays import com.threegap.bitnagil.presentation.routinelist.model.RoutineListIntent @@ -24,6 +25,7 @@ class RoutineListViewModel @Inject constructor( private val fetchWeeklyRoutinesUseCase: FetchWeeklyRoutinesUseCase, private val deleteRoutineUseCase: DeleteRoutineUseCase, private val deleteRoutineForDayUseCase: DeleteRoutineForDayUseCase, + private val getWriteRoutineEventFlowUseCase: GetWriteRoutineEventFlowUseCase, ) : MviViewModel( savedStateHandle = savedStateHandle, initState = RoutineListState( @@ -38,6 +40,7 @@ class RoutineListViewModel @Inject constructor( init { fetchRoutines() + observeRoutineChanges() } override suspend fun SimpleSyntax.reduceState( @@ -114,6 +117,14 @@ class RoutineListViewModel @Inject constructor( return newState } + private fun observeRoutineChanges() { + viewModelScope.launch { + getWriteRoutineEventFlowUseCase().collect { + fetchRoutines() + } + } + } + private fun fetchRoutines() { sendIntent(RoutineListIntent.UpdateLoading(true)) val currentWeek = stateFlow.value.selectedDate.getCurrentWeekDays()