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 Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,15 +2,12 @@ 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
65import javax.inject.Inject
76
87class FetchWeeklyRoutinesUseCase @Inject constructor(
98 private val routineRepository : RoutineRepository ,
109) {
11- suspend operator fun invoke (currentWeeks : List <LocalDate >): Result <RoutineSchedule > {
12- val startDate = currentWeeks.first().toString()
13- val endDate = currentWeeks.last().toString()
10+ suspend operator fun invoke (startDate : String , endDate : String ): Result <RoutineSchedule > {
1411 return routineRepository.fetchWeeklyRoutines(startDate, endDate)
1512 }
1613}
Original file line number Diff line number Diff line change @@ -264,7 +264,9 @@ class HomeViewModel @Inject constructor(
264264 private suspend fun fetchWeeklyRoutines (currentWeeks : List <LocalDate >) {
265265 subIntent {
266266 reduce { state.copy(loadingCount = state.loadingCount + 1 ) }
267- fetchWeeklyRoutinesUseCase(currentWeeks).fold(
267+ val startDate = currentWeeks.first().toString()
268+ val endDate = currentWeeks.last().toString()
269+ fetchWeeklyRoutinesUseCase(startDate, endDate).fold(
268270 onSuccess = {
269271 reduce { state.copy(routineSchedule = it.toUiModel(), loadingCount = state.loadingCount - 1 ) }
270272 },
Original file line number Diff line number Diff line change @@ -128,8 +128,10 @@ 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()
131133 viewModelScope.launch {
132- fetchWeeklyRoutinesUseCase(currentWeek ).fold(
134+ fetchWeeklyRoutinesUseCase(startDate, endDate ).fold(
133135 onSuccess = { routines ->
134136 sendIntent(RoutineListIntent .LoadRoutines (routines.toUiModel()))
135137 sendIntent(RoutineListIntent .UpdateLoading (false ))
You can’t perform that action at this time.
0 commit comments