diff --git a/src/addons/calendar/pages/edit-event/edit-event.page.ts b/src/addons/calendar/pages/edit-event/edit-event.page.ts index d7bcfd094..c1807d35f 100644 --- a/src/addons/calendar/pages/edit-event/edit-event.page.ts +++ b/src/addons/calendar/pages/edit-event/edit-event.page.ts @@ -520,7 +520,7 @@ export class AddonCalendarEditEventPage implements OnInit, OnDestroy, CanLeave { try { const result = await AddonCalendar.submitEvent(this.eventId, data, { - reminders: this.reminders, + reminders: this.eventId ? [] : this.reminders, // Only allow adding reminders for new events. }); event = result.event; @@ -638,7 +638,8 @@ export class AddonCalendarEditEventPage implements OnInit, OnDestroy, CanLeave { * @return Promise resolved when done. */ protected async initReminders(): Promise { - if (!this.notificationsEnabled) { + // Don't init reminders when editing an event. Right now, only allow adding reminders for new events. + if (!this.notificationsEnabled || this.eventId) { return; } diff --git a/src/addons/calendar/services/calendar.ts b/src/addons/calendar/services/calendar.ts index ec8c8db11..817b44ee1 100644 --- a/src/addons/calendar/services/calendar.ts +++ b/src/addons/calendar/services/calendar.ts @@ -1696,7 +1696,7 @@ export class AddonCalendarProvider { const event = await AddonCalendarOffline.saveEvent(eventId, formData, siteId); // Now save the reminders if any. - if (options.reminders) { + if (options.reminders?.length) { await CoreUtils.ignoreErrors( Promise.all(options.reminders.map((reminder) => this.addEventReminder(event, reminder.time, siteId))), ); @@ -1718,7 +1718,7 @@ export class AddonCalendarProvider { const event = await this.submitEventOnline(eventId, formData, siteId); // Now save the reminders if any. - if (options.reminders) { + if (options.reminders?.length) { await CoreUtils.ignoreErrors( Promise.all(options.reminders.map((reminder) => this.addEventReminder(event, reminder.time, siteId))), );