Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[expo-calendar] Fix recurrence rule and event parsing #7527

Merged
merged 3 commits into from May 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 13 additions & 0 deletions apps/test-suite/tests/Calendar.js
Expand Up @@ -337,6 +337,19 @@ export async function test(t) {
t.expect(typeof eventId).toBe('string');
});

t.it('creates an event with the recurrence rule', async () => {
const eventId = await createTestEventAsync(calendarId, {
recurrenceRule: {
endDate: new Date(2019, 3, 5),
frequency: 'daily',
interval: 1,
},
});

t.expect(eventId).toBeDefined();
t.expect(typeof eventId).toBe('string');
});

if (Platform.OS === 'ios') {
t.it('rejects when time zone is invalid', async () => {
let error;
Expand Down
1 change: 1 addition & 0 deletions packages/expo-calendar/CHANGELOG.md
Expand Up @@ -9,3 +9,4 @@
### 🐛 Bug fixes

- Fixed `Calendar.getCalendarsAsync` requiring not needed permissions on iOS. ([#7928](https://github.com/expo/expo/pull/7928) by [@lukmccall](https://github.com/lukmccall))
- Fix `recurrence rule` and `event` parsing. ([#7527](https://github.com/expo/expo/pull/7527) by [@lukmccall](https://github.com/lukmccall))
6 changes: 5 additions & 1 deletion packages/expo-calendar/build/Calendar.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/expo-calendar/build/Calendar.js.map

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion packages/expo-calendar/src/Calendar.ts
Expand Up @@ -701,7 +701,11 @@ function stringifyIfDate(date: any): any {

function stringifyDateValues(obj: object): object {
return Object.keys(obj).reduce((acc, key) => {
acc[key] = stringifyIfDate(obj[key]);
const value = obj[key];
if (typeof value === 'object' && !(value instanceof Date)) {
return { ...acc, [key]: stringifyDateValues(value) };
}
acc[key] = stringifyIfDate(value);
return acc;
}, {});
}