From c878e51fcecca631d0fa30126ebefc6ede791efe Mon Sep 17 00:00:00 2001 From: Linus Rath <139418639+rathlinus@users.noreply.github.com> Date: Tue, 13 Oct 2026 15:48:35 +0200 Subject: [PATCH] fix: clear a calendar's default reminders with an empty list instead of null #1209 --- .../__tests__/calendar-default-alerts-settings.test.tsx | 4 ++-- components/settings/calendar-management-settings.tsx | 9 +++------ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/components/settings/__tests__/calendar-default-alerts-settings.test.tsx b/components/settings/__tests__/calendar-default-alerts-settings.test.tsx index c80aea02b..d1ff6ac1f 100644 --- a/components/settings/__tests__/calendar-default-alerts-settings.test.tsx +++ b/components/settings/__tests__/calendar-default-alerts-settings.test.tsx @@ -78,7 +78,7 @@ describe('Calendar default reminders settings', () => { ); }); - it('clears a list by sending null once its last reminder is removed', async () => { + it('clears a list by sending an empty map, which Stalwart accepts where it refuses null', async () => { useCalendarStore.setState({ calendars: [makeCalendar({ defaultAlertsWithTime: { @@ -93,6 +93,6 @@ describe('Calendar default reminders settings', () => { fireEvent.click(screen.getByText('save')); await waitFor(() => expect(updateCalendar).toHaveBeenCalledTimes(1)); - expect(updateCalendar.mock.calls[0][2]).toEqual({ defaultAlertsWithTime: null, defaultAlertsWithoutTime: null }); + expect(updateCalendar.mock.calls[0][2]).toEqual({ defaultAlertsWithTime: {}, defaultAlertsWithoutTime: {} }); }); }); diff --git a/components/settings/calendar-management-settings.tsx b/components/settings/calendar-management-settings.tsx index 5c88d38d2..b6e9d6681 100644 --- a/components/settings/calendar-management-settings.tsx +++ b/components/settings/calendar-management-settings.tsx @@ -172,13 +172,10 @@ export function CalendarDefaultAlertsForm({ const [timedRows, setTimedRows] = useState(timed.rows); const [allDayRows, setAllDayRows] = useState(allDay.rows); - const toMap = (rows: AlertRow[], preserved: typeof timed.preserved) => { - const map = rowsToAlerts(rows, preserved); - return Object.keys(map).length > 0 ? map : null; - }; + // An emptied list is sent as {}: Stalwart refuses null for these maps. const submit = () => onSave({ - defaultAlertsWithTime: toMap(timedRows, timed.preserved), - defaultAlertsWithoutTime: toMap(allDayRows, allDay.preserved), + defaultAlertsWithTime: rowsToAlerts(timedRows, timed.preserved), + defaultAlertsWithoutTime: rowsToAlerts(allDayRows, allDay.preserved), }); return (