mirror of
https://github.com/bulwarkmail/webmail.git
synced 2026-10-31 00:12:39 +00:00
fix: clear a calendar's default reminders with an empty list instead of null #1209
This commit is contained in:
@@ -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: {} });
|
||||
});
|
||||
});
|
||||
|
||||
@@ -172,13 +172,10 @@ export function CalendarDefaultAlertsForm({
|
||||
const [timedRows, setTimedRows] = useState<AlertRow[]>(timed.rows);
|
||||
const [allDayRows, setAllDayRows] = useState<AlertRow[]>(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 (
|
||||
|
||||
Reference in New Issue
Block a user