File tree Expand file tree Collapse file tree 1 file changed +14
-10
lines changed
Expand file tree Collapse file tree 1 file changed +14
-10
lines changed Original file line number Diff line number Diff line change @@ -12,16 +12,20 @@ async function loadEvents(query = defaultQuery) {
1212 const response = await fetch ( query ) ;
1313 const evnts = await response . json ( ) ;
1414
15- const grist = await fetch ( 'https://grist.hentou.org/api/docs/fRo9SxKZ7NnJnN4vkNrg1s/tables/Kerlandrier/records' )
16- const gristData = await grist . json ( ) ;
17- const gristEvnts = gristData . records . map ( ( data ) =>
18- data . fields
19- )
20-
21- const upcomingGristEvnts = gristEvnts . filter ( ( e ) => new Date <= new Date ( e . end_date_time * 1000 ) )
22-
23- const allEvnts = [ ...evnts . events , ...upcomingGristEvnts ]
24-
15+ const grist = await fetch ( 'https://grist.hentou.org/api/docs/fRo9SxKZ7NnJnN4vkNrg1s/tables/Kerlandrier/records' ) ;
16+ const gristData = grist . status === 200
17+ ? await grist . json ( )
18+ : null ;
19+ const gristEvnts = ( gristData && gristData . records )
20+ ? gristData . records . map ( ( data ) => data . fields )
21+ : { } ;
22+ const upcomingGristEvnts = ( gristEvnts . length > 0 )
23+ ? gristEvnts . filter ( ( e ) => new Date ( ) <= new Date ( e . end_date_time * 1000 ) )
24+ : [ ] ;
25+
26+ // Merge OA events with Grist events
27+ const allEvnts = [ ...evnts . events , ...upcomingGristEvnts ] ;
28+
2529 const sortedAllEvnts = allEvnts . sort ( ( a , b ) => {
2630 const dateA = new Date ( a . nextTiming ?. begin ?? a . start_date_time * 1000 ) ;
2731 const dateB = new Date ( b . nextTiming ?. begin ?? b . start_date_time * 1000 ) ;
You can’t perform that action at this time.
0 commit comments