Skip to content

Commit 773c1d5

Browse files
committed
Fix bug with infinite while loop in GetAllStreaksWithCashingUseCase
The while loop in GetAllStreaksWithCashingUseCase ran infinitely when the habit start date was in the future.
1 parent de094f3 commit 773c1d5

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

core/domain/src/main/java/com/rendox/routinetracker/core/domain/streak/GetAllStreaksWithCashingUseCase.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ class GetAllStreaksWithCashingUseCase(
5050
val firstDateToLookFor = habit.schedule.startDate
5151
var period = getPeriodRange(habit.schedule, firstDateToLookFor)!!
5252

53+
if (period.start > today) return@withContext emptyList<Streak>()
54+
5355
while (!period.contains(today)) {
5456
val cashedStreaksContainsPeriod = cashedPeriods.any { cashedPeriod ->
5557
period.isSubsetOf(cashedPeriod)

0 commit comments

Comments
 (0)