Fix skip days for short toggle

pull/2012/head
Dharanish 1 year ago
parent 21d8a008f1
commit 73fcf2e238

@ -89,12 +89,12 @@ class CheckmarkButtonView(
}
fun performToggle() {
value = Entry.nextToggleValue(
val next_value = Entry.nextToggleValue(
value = value,
isSkipEnabled = preferences.isSkipEnabled,
areQuestionMarksEnabled = preferences.areQuestionMarksEnabled
)
onToggle(value, notes)
onToggle(next_value, notes)
performHapticFeedback(HapticFeedbackConstants.LONG_PRESS)
invalidate()
}

@ -137,11 +137,15 @@ open class ListHabitsBehavior @Inject constructor(
}
fun onToggle(habit: Habit, timestamp: Timestamp, value: Int, notes: String, x: Float, y: Float) {
if (habit.skipDays.isDaySkipped(timestamp)) {
commandRunner.run(BlockSkippedDayCommand())
} else {
commandRunner.run(
CreateRepetitionCommand(habitList, habit, timestamp, value, notes)
)
if (value == YES_MANUAL) screen.showConfetti(habit.color, x, y)
}
}
enum class Message {
COULD_NOT_EXPORT,

@ -21,6 +21,7 @@ package org.isoron.uhabits.core.ui.screens.habits.show.views
import org.isoron.platform.time.DayOfWeek
import org.isoron.platform.time.LocalDate
import org.isoron.uhabits.core.commands.BlockSkippedDayCommand
import org.isoron.uhabits.core.commands.CommandRunner
import org.isoron.uhabits.core.commands.CreateRepetitionCommand
import org.isoron.uhabits.core.models.Entry
@ -67,7 +68,10 @@ class HistoryCardPresenter(
override fun onDateLongPress(date: LocalDate) {
val timestamp = Timestamp.fromLocalDate(date)
screen.showFeedback()
if (habit.skipDays.isDaySkipped(timestamp)) return
if (habit.skipDays.isDaySkipped(timestamp)) {
commandRunner.run(BlockSkippedDayCommand())
return
}
if (habit.isNumerical) {
showNumberPopup(timestamp)
} else {
@ -82,7 +86,10 @@ class HistoryCardPresenter(
override fun onDateShortPress(date: LocalDate) {
val timestamp = Timestamp.fromLocalDate(date)
screen.showFeedback()
if (habit.skipDays.isDaySkipped(timestamp)) return
if (habit.skipDays.isDaySkipped(timestamp)) {
commandRunner.run(BlockSkippedDayCommand())
return
}
if (habit.isNumerical) {
showNumberPopup(timestamp)
} else {

Loading…
Cancel
Save