wmcmahan / react-native-calendar-events

📆 React Native Module for iOS and Android Calendar Events
MIT License
906 stars 292 forks source link

List of calendars not syncing with device calendars #345

Open minuhariharan opened 3 years ago

minuhariharan commented 3 years ago

I am using the findCalendars API to fetch the list of all device calendars. Initially I get the correct list of calendars, say A, B, C. If I add a new calendar D, and invoke the findCalendars API again in my app when a screen loads, then the new calendar D does not show up. If I delete a calendar say A, I still see it in the list of calendars, and in face I am able to save an event to calendar A, and no error is thrown. I wanted to know does the library maintain a cache of calendars, how can I force the library to be in sync with the device calendars?

Environment

OS: macOS 11.1 CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz Memory: 353.38 MB / 16.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 15.3.0 - /usr/local/bin/node Yarn: 1.22.10 - /usr/local/bin/yarn npm: 7.0.14 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman Managers: CocoaPods: 1.10.0. - /usr/local/bin/pod SDKs: iOS SDK: Platforms: iOS 14.3, DriverKit 20.2, macOS 11.1, tvOS 14.3, watchOS 7.2 Android SDK: API Levels: 26, 28, 29 Build Tools: 28.0.3, 29.0.2 System Images: android-29 | Google APIs Intel x86 Atom, android-30 | Google Play Intel x86 Atom Android NDK: Not Found IDEs: Android Studio: 4.1 AI-201.8743.12.41.6953283 Xcode: 12.3/12C33 - /usr/bin/xcodebuild Languages: Java: 1.8.0_212 - /Library/Java/JavaVirtualMachines/jdk1.8.0_212.jdk/Contents/Home/bin/javac Python: 2.7.16 - /usr/local/bin/python npmPackages: @react-native-community/cli: Not Found react: ^16.13.1 => 16.13.1 react-native: ^0.63.3 => 0.63.3 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found

Steps to Reproduce

  1. calendars = await RNCalendarEvents.findCalendars()

  2. Display the calendar list

  3. Delete or add a new calendar on the device or via google calendar API

  4. Get the list of calendars again, the newly added or deleted calendars are not synced. Newly added won't appear, and existing calendar that is deleted will still show

Expected Behavior

The calendar list should be in sync with the device

Actual Behavior

If I add or remove a calendar via the Google calendar API, I don't see those changes when I query and get the list of calendars. Only if I delete the app and install it again I see the new calendars, or see calendars deleted are removed. Please help me understand why this is happening and any possible fix for the same.

wmcmahan commented 3 years ago

@minuhariharan This library doesn’t add any extra caching and reads directly from the calendars synced on the device via native sdk. Seems like maybe the added calendar is not synced before the calendars query is made?

minuhariharan commented 3 years ago

The calendars list is updated after a while, for example I checked last night, deleted a calendar and it was showing until today afternoon. Wonder if it takes such a long time for the calendars to sync, the same applies to a new calendar it does not appear immediately.