File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -11,19 +11,20 @@ export async function fetchCommunityEvents(): Promise<CommunityEventsReturnType>
11
11
12
12
try {
13
13
const futureEventsReq = await fetch (
14
- `https://content.googleapis.com/calendar/v3/calendars/${ calendarId } /events?key=${ apiKey } &timeMin=${ new Date ( ) . toISOString ( ) } &maxResults=3`
14
+ `https://content.googleapis.com/calendar/v3/calendars/${ calendarId } /events?key=${ apiKey } &timeMin=${ new Date ( ) . toISOString ( ) } &maxResults=3&singleEvents=true&orderby=starttime `
15
15
)
16
16
const futureEvents = await futureEventsReq . json ( )
17
17
const futureEventsReqData : ReqCommunityEvent [ ] = futureEvents . items
18
18
19
19
const pastEventsReq = await fetch (
20
- `https://content.googleapis.com/calendar/v3/calendars/${ calendarId } /events?key=${ apiKey } &timeMax=${ new Date ( ) . toISOString ( ) } &maxResults=4 `
20
+ `https://content.googleapis.com/calendar/v3/calendars/${ calendarId } /events?key=${ apiKey } &timeMax=${ new Date ( ) . toISOString ( ) } &orderby=starttime `
21
21
)
22
22
const pastEvents = await pastEventsReq . json ( )
23
23
const pastEventsReqData : ReqCommunityEvent [ ] = pastEvents . items
24
24
25
25
const pastEventData = pastEventsReqData
26
26
. filter ( ( event ) => event . start )
27
+ . slice ( - 4 )
27
28
. map ( ( event ) => {
28
29
return {
29
30
date : event . start . dateTime ,
@@ -34,6 +35,7 @@ export async function fetchCommunityEvents(): Promise<CommunityEventsReturnType>
34
35
} )
35
36
const upcomingEventData = futureEventsReqData
36
37
. filter ( ( event ) => event . start )
38
+ . reverse ( )
37
39
. map ( ( event ) => {
38
40
return {
39
41
date : event . start . dateTime ,
You can’t perform that action at this time.
0 commit comments