Skip to content

Commit f39ea30

Browse files
committed
add an "eventMapper" prop to calendar-google
allows editing events after they're fetched, but before they're rendered in the list. Lets us take advantage of the new "config" property to clean up events from certain data sources, if needed.
1 parent 5a33f49 commit f39ea30

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

source/views/calendar/calendar-google.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ import qs from 'querystring'
1313
import {GOOGLE_CALENDAR_API_KEY} from '../../lib/config'
1414
const TIMEZONE = 'America/Winnipeg'
1515

16-
type Props = TopLevelViewPropsType & {calendarId: string, poweredBy: ?PoweredBy}
16+
type Props = TopLevelViewPropsType & {
17+
calendarId: string,
18+
eventMapper?: EventType => EventType,
19+
poweredBy: ?PoweredBy,
20+
}
1721

1822
type State = {
1923
events: EventType[],
@@ -52,7 +56,7 @@ export class GoogleCalendarView extends React.Component<Props, State> {
5256
}
5357

5458
convertEvents(data: GoogleEventType[], now: moment): EventType[] {
55-
return data.map(event => {
59+
let events = data.map(event => {
5660
const startTime = moment(event.start.date || event.start.dateTime)
5761
const endTime = moment(event.end.date || event.end.dateTime)
5862

@@ -70,6 +74,12 @@ export class GoogleCalendarView extends React.Component<Props, State> {
7074
},
7175
}
7276
})
77+
78+
if (this.props.eventMapper) {
79+
events = events.map(this.props.eventMapper)
80+
}
81+
82+
return events
7383
}
7484

7585
getEvents = async (now: moment = moment.tz(TIMEZONE)) => {

0 commit comments

Comments
 (0)