Drop reminders when a task loses its last date (#159)
This commit is contained in:
1 parent
3e34c60577
commit
e2275745da
1 file changed
+15
-2
@@ -316,8 +316,21 @@ class TaskEditViewModel @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
fun onStartChange(value: Instant?) = update { it.copy(start = value).withDefaultReminders() }
|
||||
fun onDueChange(value: Instant?) = update { it.copy(due = value).withDefaultReminders() }
|
||||
fun onStartChange(value: Instant?) = update {
|
||||
it.copy(start = value).withDefaultReminders().withoutDatelessReminders()
|
||||
}
|
||||
fun onDueChange(value: Instant?) = update {
|
||||
it.copy(due = value).withDefaultReminders().withoutDatelessReminders()
|
||||
}
|
||||
|
||||
/** A task left without dates has nothing for its reminders to count from, so they go with the last one (#159). */
|
||||
private fun TaskEditUiState.withoutDatelessReminders(): TaskEditUiState =
|
||||
if (start != null || due != null || reminders.isEmpty()) {
|
||||
this
|
||||
} else {
|
||||
copy(reminders = emptyList(), remindersChosen = true)
|
||||
}
|
||||
|
||||
/**
|
||||
* All-day and timed values use different conventions (UTC midnight vs. a real
|
||||
* instant in the device zone), so the switch has to move the timestamps too —
|
||||
|
||||
Reference in new issue
Block a user