MOBILE-3909 calendar: Fix default reminder duplicated when editing
parent
1db5b85e40
commit
c0b170b5f0
|
@ -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<void> {
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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))),
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue