Skip to content

Commit

Permalink
Hide failed habits along with completed ones
Browse files Browse the repository at this point in the history
  • Loading branch information
hiqua committed Aug 4, 2021
1 parent cc38c75 commit e7d61b7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,19 @@ data class Habit(
}
}

fun isFailedToday(): Boolean {
val today = DateUtils.getTodayWithOffset()
val value = computedEntries.get(today).value
return if (isNumerical) {
when (targetType) {
NumericalHabitType.AtLeast -> value / 1000.0 < targetValue
NumericalHabitType.AtMost -> value / 1000.0 > targetValue
}
} else {
value == Entry.NO
}
}

fun recompute() {
computedEntries.recomputeFrom(
originalEntries = originalEntries,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ data class HabitMatcher(
fun matches(habit: Habit): Boolean {
if (!isArchivedAllowed && habit.isArchived) return false
if (isReminderRequired && !habit.hasReminder()) return false
if (!isCompletedAllowed && habit.isCompletedToday()) return false
if (!isCompletedAllowed && (habit.isCompletedToday() || habit.isFailedToday())) return false
return true
}

Expand Down

0 comments on commit e7d61b7

Please sign in to comment.