react-native-calendar-events: Removing many events causes them to sporadically reappear

When I remove and create many events (around 50) in quick succession (around 5 seconds apart), it sometimes doesn’t delete the old events, but instead, just adds the new events. I don’t get any errors removing the old events either.

Is there maybe some kind of limit to how many times you can hit the calendar API before it starts to ignore requests?

I’ve tried to be a bit “slower” in how I hit the calendar, for example, waiting until all the events are removed before I add them (with callbacks).

For some odd reason I can’t reproduce this with the simulator, I have to use the app on my iPhone.

Environment

Environment: OS: macOS High Sierra 10.13.6 Node: 9.4.0 Yarn: 1.1.0 npm: 3.3.10 Watchman: 4.5.0 Xcode: Xcode 9.4.1 Build version 9F2000 Android Studio: 2.3 AI-162.4069837

Packages: (wanted => installed) react: 16.3.1 => 16.3.1 react-native: 0.55.3 => 0.55.3

Steps to Reproduce

(in quick succession)

  1. Add many events (around 50).
  2. Delete all of them.
  3. Add many more events.
  4. Notice it didn’t delete the old events, but just added the new ones.

Here’s the “deleteCalendarEvents” function:

export const deleteCalendarEvents = function deleteCalendarEvents(params) {
  let deletePromiseChain = [];
  let eventIds = params.eventIds;

  RNCalendarEvents.authorizeEventStore().then(fulfilled => {
    if (fulfilled === "authorized") {
      _.forEach(eventIds, (eventId) => {
        deletePromiseChain.push(
          RNCalendarEvents.removeEvent(eventId).then(event => {
            console.log('deleted event', event);
          })
          .catch(error => {
            console.log('delete event error', error);
          })
        );
      });

      Promise.all(deletePromiseChain).then(
        success => {
          if (params.callback) {
            params.callback();
          }
        },
        rejected => syncErrorAlert()
      );
    } else {
      authErrorAlert();
    }
  });
};

Expected Behavior

It removes and creates many events in quick succession without a problem.

Actual Behavior

It doesn’t delete old events.

before after

About this issue

  • Original URL
  • State: open
  • Created 6 years ago
  • Comments: 26 (4 by maintainers)

Most upvoted comments

@wmcmahan

I think I met the similar issue, I found that when I set the saveEvent option like this:

await RNCalendarEvents.saveEvent(title, {
          startDate,
          endDate,
          recurrenceRule: {
            frequency: 'weekly',
            occurrence,
            interval,
          },
          location,
          notes: 'my notes',
          alarms: [{
            date: -5,
          }]
        }, {
          futureEvents: true,
        });
  • The recurrenceRule and location cause saveEvent method can’t complete
  • The alarms may cause app crashed (but not every times).

It only happens when I want to save more than one event. I used forEach to traverse and save different events.

If I removed recurrenceRule, location and alarms, it works fine. Can you reproduce this issue?

p.s. My React-Native version is 0.52.0. My react-native-calendar-events version is 1.6.3. Running on iOS 11.4 Simulator.

@jmagdada Our fork is up to date with master in the base fork, so to try out our patch you can also set your npm dependency in your package.json file to "react-native-calendar-events": "github:Outpatient/react-native-calendar-events#a7d8ef51c842b944011d478d7e003fbabe829443",. In my experience, you may need to first run npm uninstall react-native-calendar-events to remove an existing version to avoid caching issues.

@jmagdada There’s probably a better way, but I just made sure I have the latest version of this library and grab the changes that were made in the PR and copy them to my node_modules/react-native-calendar-events directory. The only thing that was changed in that PR was https://raw.githubusercontent.com/wmcmahan/react-native-calendar-events/a7d8ef51c842b944011d478d7e003fbabe829443/RNCalendarEvents.m

So I copied the entire contents of that file and overwrote the entire contents of that file that I have locally.