Avoid getCalendarById on HarmonyOS to fix isPrimary column error#1114
Conversation
HarmonyOS 4.2.0 does not expose the `isPrimary` column directly in the calendar content provider — it's only available as a COALESCE expression. expo-calendar's native `getCalendarById` queries this column, causing an IllegalArgumentException crash when syncing assignments on Huawei devices. Replace Calendar.ExpoCalendar.get(calendarId) with Calendar.getCalendars() followed by a find-by-id lookup, which uses a different native code path that does not query isPrimary directly. Fixes #1112 Co-authored-by: Rui Ying <robertying@users.noreply.github.com>
|
@claude can you fix and patch the source instead? |
|
Claude finished @robertying's task in 9m 38s —— View job Tasks
|
Instead of working around the bug in JS, patch the native source. expo-calendar's next-module `CalendarRepository.findById` queries the calendar *item* URI (ContentUris.withAppendedId) with `isPrimary` in its projection. On HarmonyOS 4.2.0 the item URI does not expose the computed `isPrimary` column, causing an IllegalArgumentException. The collection URI used by `findAll`/`getCalendars` does expose it, which is why that path works. Patch `findById` to query the collection URI with an `_ID = ?` filter (the same path that works for `getCalendars`), and revert the JS-level workaround in src/helpers/event.ts so it uses `ExpoCalendar.get` again. Fixes #1112 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

HarmonyOS 4.2.0 does not expose the
isPrimarycolumn directly in the calendar content provider — it's only available as a COALESCE expression. expo-calendar's nativegetCalendarByIdqueries this column, causing an IllegalArgumentException crash when syncing assignments on Huawei devices.Replace
Calendar.ExpoCalendar.get(calendarId)withCalendar.getCalendars()followed by a find-by-id lookup, which uses a different native code path that does not query isPrimary directly.Fixes #1112
Generated with Claude Code