diff --git a/app.js b/app.js index 10f95af..b86cad2 100644 --- a/app.js +++ b/app.js @@ -1,26 +1,21 @@ import { h } from 'preact' import { useState, useEffect } from 'preact/hooks' -import 'regenerator-runtime/runtime' -import axios from 'axios' +import { isWithinInterval, subHours } from 'date-fns' +import { addHours } from 'date-fns/esm' import Video from './src/components/Video' import config from './src/data/config' import Info from './src/components/Info' -import { useCalendar } from './src/hooks/data' +import { useEventStream } from './src/hooks/data' import { useTimeout } from './src/hooks/timerHooks' -// const appStates = [ -// 'noStream', -// 'streamLive', -// 'streamFinished' -// ] - export default () => { const [isPlaying, setIsPlaying] = useState(false) - const [videoUrl, setVideoUrl] = useState(null) - const [feedData, setFeedData] = useState([]) + const [currentVideo, setCurrentVideo] = useState(null) + const [streamIsLive, setStreamLive] = useState(false) + const [infoActive, setInfoActive] = useState(false) const [minLoadTimePassed, setMinTimeUp] = useState(false) - const { data, loading } = useCalendar() + const { data, loading } = useEventStream() useTimeout(() => { setMinTimeUp(true) @@ -28,40 +23,26 @@ export default () => { useEffect(() => { if (data && data.length) { - data.forEach(async (calItem, index) => { - if (calItem.url) { - const id = calItem.url.val.split('/').pop() - - const { - data: { - account, - category, - channel, - embedPath, - language, - name, - state, - previewPath, - views, - }, - } = await axios.get(`https://tv.undersco.re/api/v1/videos/${id}`) - - const item = { - name, - account, - category, - channel, - description: calItem.description, - embedPath, - language, - state, - previewPath, - views, - start: calItem.start, - end: calItem.end, - id, - } - setFeedData(arr => [...arr, item]) + data.forEach((stream, index) => { + // if (stream.title === 'A Wider Screen') { + if (index === 0) { + setCurrentVideo(stream) + } + if ( + isWithinInterval(new Date(), { + start: subHours(stream.start, 1), + end: addHours(stream.end, 1), + }) + ) { + setCurrentVideo(stream) + } + if ( + isWithinInterval(new Date(), { + start: stream.start, + end: stream.end, + }) + ) { + setStreamLive(`${config.peertube_root}${stream.embedPath}`) } }) } @@ -69,16 +50,23 @@ export default () => { return (
- {false ? ( + {currentVideo && !infoActive && minLoadTimePassed ? (
) diff --git a/package.json b/package.json index 9dd4d37..c29f780 100644 --- a/package.json +++ b/package.json @@ -35,4 +35,4 @@ "sass": "^1.32.8", "scss": "^0.2.4" } -} +} \ No newline at end of file diff --git a/src/assets/img/IconSM.png b/src/assets/img/IconSM.png new file mode 100644 index 0000000..d554c12 Binary files /dev/null and b/src/assets/img/IconSM.png differ diff --git a/src/assets/theme/index.js b/src/assets/theme/index.js index 3471bfb..35bb412 100644 --- a/src/assets/theme/index.js +++ b/src/assets/theme/index.js @@ -3,7 +3,7 @@ export const colours = { midnightDarker: '#112B39', offwhite: '#f6f4f5', - white: '#fff', + white: '#ffffff', highlight: '#03a59e', roseDarker: '#FEB9B3', rose: '#F1CFCD', diff --git a/src/components/Chat/index.js b/src/components/Chat/index.js index c377332..d7771d9 100644 --- a/src/components/Chat/index.js +++ b/src/components/Chat/index.js @@ -1,19 +1,40 @@ import { h } from 'preact' +import { useEffect, useRef, useState } from 'preact/hooks' +import { useWindowDimensions } from '../../hooks/dom' +import { useToggle } from '../../hooks/utility' -import { ChatWrapper } from './styles' +import { Label } from '../Text' +import { ChatFrame, ChatWrapper, ChatHeader, CloseBox } from './styles' +import { colours } from '../../assets/theme' const Chat = ({}) => { - return ( + const { width, height } = useWindowDimensions() + const [chatIsOpen, toggleChatOpen] = useToggle(true) + return chatIsOpen ? ( -