Skip to content

Commit 2a655e9

Browse files
committed
Fix: 루틴 완료 로직 수정
- 중복 검증 처리 제거
1 parent 5d01e7a commit 2a655e9

1 file changed

Lines changed: 4 additions & 10 deletions

File tree

  • presentation/src/main/java/com/threegap/bitnagil/presentation/home

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

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -300,21 +300,15 @@ class HomeViewModel @Inject constructor(
300300

301301
val routine = routinesForDate[routineIndex]
302302

303-
if (subRoutineIndex < 0 || subRoutineIndex >= routine.subRoutineNames.size) {
303+
if (subRoutineIndex !in routine.subRoutineCompleteYn.indices) {
304304
return@updateRoutinesForDate false
305305
}
306306

307-
val updatedSubRoutineCompleteYn = routine.subRoutineCompleteYn.toMutableList().apply {
308-
if (subRoutineIndex < size) {
309-
this[subRoutineIndex] = isCompleted
310-
}
307+
val updatedSubRoutineCompleteYn = routine.subRoutineCompleteYn.toMutableList().also {
308+
it[subRoutineIndex] = isCompleted
311309
}
312310

313-
val routineCompleted = if (isCompleted) {
314-
updatedSubRoutineCompleteYn.all { it }
315-
} else {
316-
false
317-
}
311+
val routineCompleted = updatedSubRoutineCompleteYn.all { it }
318312

319313
val updatedRoutine = routine.copy(
320314
subRoutineCompleteYn = updatedSubRoutineCompleteYn,

0 commit comments

Comments
 (0)