diff --git a/.eslintrc b/.eslintrc index f9796f6..cbd3b89 100644 --- a/.eslintrc +++ b/.eslintrc @@ -3,6 +3,7 @@ "rules": { "indent": ["error", 2], "import/prefer-default-export": 0, - "react/require-default-props": 0 + "react/require-default-props": 0, + "react/forbid-prop-types": 0 } } diff --git a/app.js b/app.js index b86cad2..0a394b7 100644 --- a/app.js +++ b/app.js @@ -10,9 +10,8 @@ import { useEventStream } from './src/hooks/data' import { useTimeout } from './src/hooks/timerHooks' export default () => { - const [isPlaying, setIsPlaying] = useState(false) const [currentVideo, setCurrentVideo] = useState(null) - const [streamIsLive, setStreamLive] = useState(false) + const [streamIsLive, setStreamIsLive] = useState(false) const [infoActive, setInfoActive] = useState(false) const [minLoadTimePassed, setMinTimeUp] = useState(false) const { data, loading } = useEventStream() @@ -42,7 +41,7 @@ export default () => { end: stream.end, }) ) { - setStreamLive(`${config.peertube_root}${stream.embedPath}`) + setStreamIsLive(true) } }) } @@ -51,14 +50,7 @@ export default () => { return (
{ @@ -11,14 +11,24 @@ export const useEventStream = () => { setLoading(true) const { data: responseData } = await axios.get(`${config.calendar}`) - const calItems = Object.values(ical.parseICS(responseData)) - .filter(feedItem => feedItem.type === 'VEVENT') - .sort((a, b) => new Date(a.start) - new Date(b.start)) + const jCalData = ICAL.parse(responseData) + const comp = new ICAL.Component(jCalData) + + const vevents = comp.getAllSubcomponents('vevent') + + const calEvents = vevents + .map(vevent => new ICAL.Event(vevent)) + .sort((a, b) => a.startDate.toJSDate() - b.startDate.toJSDate()) await Promise.all( - calItems.map(async calItem => { - if (calItem.url) { - const id = calItem.url.val.split('/').pop() + calEvents.map(async calItem => { + const url = calItem.component.getAllProperties('url')[0] + if (url) { + console.log('url', url) + const id = url + .getFirstValue() + .split('/') + .pop() const { data: { account, @@ -31,11 +41,8 @@ export const useEventStream = () => { views, duration, }, - data: nesd, } = await axios.get(`https://tv.undersco.re/api/v1/videos/${id}`) - console.log({ nesd }) - const item = { title: calItem.summary, account, @@ -47,11 +54,11 @@ export const useEventStream = () => { state, previewPath, views, - start: calItem.start, - end: calItem.end, + start: calItem.startDate.toJSDate(), + end: calItem.endDate.toJSDate(), id, duration, - videoUrl: calItem?.url?.val, + videoUrl: url.getFirstValue(), } setData(arr => [...arr, item]) }