Drop start defaults from a start of now, address review (#178)

This commit is contained in:
makiolaj committed 2026-11-25 12:15:45 +01:00
1 parent 8e124fdb0e
commit a0fb9e5c72
4 files changed
+7 -5

No files matched your search

+2 -1
View File
@@ -63,7 +63,8 @@ All notable changes to this project are documented here. The format follows
- A task with only a start date gets the default reminder too, counted from
its start, when none of the default reminders is set from the start. Likewise
a task with only a due date gets reminders set from the start, counted from
its due date (#178).
its due date. This reaches tasks you already have that have no reminders of
their own (#178).
## [1.3.2] - 2026-11-13
@@ -235,7 +235,8 @@ internal object StoredReminders {
/**
* The defaults [form] takes, of the dates it has (see [forDates]). A one-off
* task leaves out what is already past — a start of "now" would ring at once.
* task leaves out what is already past, and any from a start of
* [now][TaskForm.startsNow], which would ring at once.
*/
private fun defaultsFor(
form: TaskForm,
@@ -245,7 +246,8 @@ internal object StoredReminders {
keepPast: Boolean = false,
): List<TaskReminder> =
settings.defaultRemindersFor(form.listId, form.isAllDay, form.start != null, form.due != null).filter { reminder ->
form.rrule != null || keepPast || ReminderPlanner.ringsAt(
if (keepPast || form.rrule != null) return@filter true
!(form.startsNow && reminder.fromStart) && ReminderPlanner.ringsAt(
TaskDates(form.start, form.due, form.isAllDay, form.untimed),
reminder.fromStart,
reminder.minutesBefore,
@@ -429,4 +429,3 @@ class ReminderPlannerTest {
.containsExactly(ScheduledReminder(12, millis(date.atTime(17, 0), berlin)))
}
}
@@ -297,6 +297,7 @@ class StoredRemindersTest {
val form = TaskForm(title = "t", listId = 1, start = now - 2.hours, startsNow = true)
assertThat(stored(form, with = Settings())).isEmpty()
assertThat(StoredReminders.pastDefaults(form, null, Settings(), now.toEpochMilliseconds(), zone)).isEmpty()
assertThat(stored(form.copy(start = now), with = Settings())).isEmpty()
}
@Test
@@ -315,4 +316,3 @@ class StoredRemindersTest {
.containsExactly(TaskReminder(1_440, fromStart = true))
}
}