File tree Expand file tree Collapse file tree
domain/src/main/java/com/threegap/bitnagil/domain/routine/usecase
presentation/src/main/java/com/threegap/bitnagil/presentation/routinelist Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,11 +2,15 @@ package com.threegap.bitnagil.domain.routine.usecase
22
33import com.threegap.bitnagil.domain.routine.model.RoutineSchedule
44import com.threegap.bitnagil.domain.routine.repository.RoutineRepository
5+ import java.time.LocalDate
56import javax.inject.Inject
67
78class FetchWeeklyRoutinesUseCase @Inject constructor(
89 private val routineRepository : RoutineRepository ,
910) {
10- suspend operator fun invoke (startDate : String , endDate : String ): Result <RoutineSchedule > =
11- routineRepository.fetchWeeklyRoutines(startDate, endDate)
11+ suspend operator fun invoke (currentWeeks : List <LocalDate >): Result <RoutineSchedule > {
12+ val startDate = currentWeeks.first().toString()
13+ val endDate = currentWeeks.last().toString()
14+ return routineRepository.fetchWeeklyRoutines(startDate, endDate)
15+ }
1216}
Original file line number Diff line number Diff line change @@ -128,10 +128,8 @@ class RoutineListViewModel @Inject constructor(
128128 private fun fetchRoutines () {
129129 sendIntent(RoutineListIntent .UpdateLoading (true ))
130130 val currentWeek = stateFlow.value.selectedDate.getCurrentWeekDays()
131- val startDate = currentWeek.first().toString()
132- val endDate = currentWeek.last().toString()
133131 viewModelScope.launch {
134- fetchWeeklyRoutinesUseCase(startDate, endDate ).fold(
132+ fetchWeeklyRoutinesUseCase(currentWeek ).fold(
135133 onSuccess = { routines ->
136134 sendIntent(RoutineListIntent .LoadRoutines (routines.toUiModel()))
137135 sendIntent(RoutineListIntent .UpdateLoading (false ))
You can’t perform that action at this time.
0 commit comments