Skip to content

Commit 18aaba1

Browse files
committed
Refactor: isCompleted 롤백
1 parent cba9a67 commit 18aaba1

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

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

33
data class RoutineToggleState(
4+
val isCompleted: Boolean,
45
val subRoutinesIsCompleted: List<Boolean>,
5-
) {
6-
val isCompleted: Boolean
7-
get() = subRoutinesIsCompleted.all { it }
8-
}
6+
)

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class ToggleRoutineUseCase @Inject constructor() {
2121
val newSubRoutineStates = subRoutineStates.map { newIsCompleted }
2222

2323
return RoutineToggleState(
24+
isCompleted = newIsCompleted,
2425
subRoutinesIsCompleted = newSubRoutineStates,
2526
)
2627
}
@@ -37,16 +38,17 @@ class ToggleRoutineUseCase @Inject constructor() {
3738
index: Int,
3839
subRoutineStates: List<Boolean>,
3940
): RoutineToggleState? {
40-
if (index !in subRoutineStates.indices) {
41-
return null
42-
}
41+
if (index !in subRoutineStates.indices) return null
4342

4443
val newState = !subRoutineStates[index]
4544
val newSubRoutineStates = subRoutineStates.toMutableList().apply {
4645
this[index] = newState
4746
}
4847

48+
val allCompleted = newSubRoutineStates.all { it }
49+
4950
return RoutineToggleState(
51+
isCompleted = allCompleted,
5052
subRoutinesIsCompleted = newSubRoutineStates,
5153
)
5254
}

0 commit comments

Comments
 (0)