Revert "fix(#365): round reminders to whole days when an event turns all-day"

This reverts commit b1e03db27c.
This commit is contained in:
makiolaj committed 2026-11-14 00:58:17 +01:00
1 parent b1e03db27c
commit a6ff2c06ef
5 files changed
+7 -27

No files matched your search

@@ -54,16 +54,6 @@ internal fun toProviderAllDayMinutes(
return if (raw == MINUTES_DEFAULT) MINUTES_DEFAULT - 1 else raw
}
/**
* Lead times rounded down to the whole days an all-day reminder can express, the
* same truncation [toProviderAllDayMinutes] applies, so the form shows what will
* be saved. [MINUTES_DEFAULT] passes through.
*/
internal fun wholeDayReminders(minutes: List<Int>): List<Int> = minutes
.map { if (it == MINUTES_DEFAULT) it else it / MINUTES_PER_DAY * MINUTES_PER_DAY }
.distinct()
.sorted()
/**
* The next date on or after [today] carrying [month]/[day] — the date to sample
* a yearly all-day reminder's UTC offset at. A managed birthday's DTSTART is an
@@ -97,7 +97,8 @@ fun ReminderDefaultPicker(
var customExpanded by rememberSaveable { mutableStateOf(false) }
var amountText by rememberSaveable { mutableStateOf("") }
var unit by rememberSaveable { mutableStateOf(units.first()) }
var pickedUnit by rememberSaveable { mutableStateOf(units.first()) }
val unit = pickedUnit.takeIf { it in units } ?: units.first()
fun apply(override: ReminderOverride) {
userEdited = true
@@ -154,7 +155,7 @@ fun ReminderDefaultPicker(
onAmountChange = { amountText = it },
units = units,
unit = unit,
onUnitChange = { unit = it },
onUnitChange = { pickedUnit = it },
onConfirm = { minutes ->
emit(selectedMinutes + minutes)
amountText = ""
@@ -1591,7 +1591,8 @@ private fun ReminderPickerDialog(
var customMode by rememberSaveable { mutableStateOf(false) }
var amountText by rememberSaveable { mutableStateOf("") }
val units = customReminderUnits(isAllDay)
var unit by rememberSaveable { mutableStateOf(units.first()) }
var pickedUnit by rememberSaveable { mutableStateOf(units.first()) }
val unit = pickedUnit.takeIf { it in units } ?: units.first()
val customMinutes = amountText.toIntOrNull()
?.takeIf { it in 1..999 }
?.let { it * unit.minutesFactor }
@@ -1643,7 +1644,7 @@ private fun ReminderPickerDialog(
DialogUnitDropdown(
label = stringResource(reminderUnitLabel(unit)),
entries = units.map { stringResource(reminderUnitLabel(it)) },
onPick = { unit = units[it] },
onPick = { pickedUnit = units[it] },
)
}
}
@@ -7,7 +7,6 @@ import androidx.lifecycle.viewModelScope
import dagger.hilt.android.lifecycle.HiltViewModel
import de.jeanlucmakiola.calendula.data.calendar.CalendarRepository
import de.jeanlucmakiola.calendula.data.calendar.NoSuchEventException
import de.jeanlucmakiola.calendula.data.calendar.wholeDayReminders
import de.jeanlucmakiola.calendula.data.ics.IcsExporter
import de.jeanlucmakiola.calendula.data.prefs.CalendarPrefs
import de.jeanlucmakiola.calendula.data.prefs.SettingsPrefs
@@ -640,12 +639,7 @@ class EventEditViewModel @Inject constructor(
// A kept pass of a repeated hour stays, so switching back out of all-day
// lands where the event was — unless dropping the pin changed the zone.
edit {
if (value) {
it.withTimezone(null, zoneSource.current())
.copy(isAllDay = true, reminders = wholeDayReminders(it.reminders))
} else {
it.copy(isAllDay = false)
}
if (value) it.withTimezone(null, zoneSource.current()).copy(isAllDay = true) else it.copy(isAllDay = false)
}
// The default reminder differs for all-day vs timed; re-apply the
// type-appropriate default unless the user has hand-edited it (guarded).
@@ -48,12 +48,6 @@ class AllDayReminderEncodingTest {
assertThat(actualFire(raw, summer)).isEqualTo(intendedFire(summer, 0, nineAm))
}
@Test
fun `whole-day rounding matches the encoder and keeps the default sentinel`() {
assertThat(wholeDayReminders(listOf(2_880, 10, 1_500, 0, MINUTES_DEFAULT)))
.containsExactly(MINUTES_DEFAULT, 0, 1_440, 2_880).inOrder()
}
@Test
fun `three weeks before fires at 9am local across a DST change`() {
val afterDst = LocalDate.of(2026, 4, 10) // CEST; three weeks earlier is CET