mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 01:08:50 -06:00
Hide failed habits along with completed ones
This commit is contained in:
@@ -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.AT_LEAST -> value / 1000.0 < targetValue
|
||||
NumericalHabitType.AT_MOST -> value / 1000.0 > targetValue
|
||||
}
|
||||
} else {
|
||||
value == Entry.NO
|
||||
}
|
||||
}
|
||||
|
||||
fun recompute() {
|
||||
computedEntries.recomputeFrom(
|
||||
originalEntries = originalEntries,
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user