From e2275745da631e2cd7d7b445a5fdd022c9fcec92 Mon Sep 17 00:00:00 2001 From: Jean-Luc Makiola Date: Thu, 12 Nov 2026 15:40:33 +0100 Subject: [PATCH] Drop reminders when a task loses its last date (#159) --- .../agendula/ui/edit/TaskEditViewModel.kt | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/de/jeanlucmakiola/agendula/ui/edit/TaskEditViewModel.kt b/app/src/main/java/de/jeanlucmakiola/agendula/ui/edit/TaskEditViewModel.kt index 1261482..fd94dc3 100644 --- a/app/src/main/java/de/jeanlucmakiola/agendula/ui/edit/TaskEditViewModel.kt +++ b/app/src/main/java/de/jeanlucmakiola/agendula/ui/edit/TaskEditViewModel.kt @@ -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 —