Skip to content

Commit cffd981

Browse files
committed
Refactor: FetchWeeklyRoutinesUseCase 파라미터 변경
1 parent d877e07 commit cffd981

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

domain/src/main/java/com/threegap/bitnagil/domain/routine/usecase/FetchWeeklyRoutinesUseCase.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@ package com.threegap.bitnagil.domain.routine.usecase
22

33
import com.threegap.bitnagil.domain.routine.model.RoutineSchedule
44
import com.threegap.bitnagil.domain.routine.repository.RoutineRepository
5+
import java.time.LocalDate
56
import javax.inject.Inject
67

78
class 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
}

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff 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))

0 commit comments

Comments
 (0)