Skip to content

Commit 2e44846

Browse files
committed
Refactor: FetchWeeklyRoutinesUseCase 인자 수정
1 parent 18aaba1 commit 2e44846

3 files changed

Lines changed: 7 additions & 6 deletions

File tree

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,12 @@ 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
65
import javax.inject.Inject
76

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

presentation/src/main/java/com/threegap/bitnagil/presentation/home/HomeViewModel.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff 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
},

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

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

0 commit comments

Comments
 (0)