Support ical calendars

This commit is contained in:
sinavir 2022-07-28 01:50:33 +02:00
parent 950d690020
commit 4dc2343917

View file

@ -1,4 +1,5 @@
import STATIC_LOCATIONS from './static-ens-locations.json'
import ICAL from 'ical.js'
// https://stackoverflow.com/a/35970186
function invertColor(hex) {
@ -208,7 +209,9 @@ function mkExportUrl(id, { cloud }) {
function fetchCalendar(id, cal, extra = {}) {
return fetch(mkCalendarUrl(id, cal, extra), { credentials: 'omit' })
.then(resp => resp.json())
.then( cal.isICS
? resp => resp.text().then(text => ICAL.parse(text))
: resp => resp.json())
.catch(err => console.error(err))
}