diff --git a/src/components/DelayDisclaimer.tsx b/src/components/DelayDisclaimer.tsx
new file mode 100644
index 0000000..7b4a6c9
--- /dev/null
+++ b/src/components/DelayDisclaimer.tsx
@@ -0,0 +1,22 @@
+import React from 'react'
+import { InformationCircleIcon } from '@heroicons/react/outline'
+
+type Props = {}
+
+export const DelayDisclaimer = ({}: Props) => {
+ return (
+
+
+
+
+
+ Expect some delay on the requests!
+
+
+
+
+ )
+}
diff --git a/src/pages/index.tsx b/src/pages/index.tsx
index e096361..8f778e3 100644
--- a/src/pages/index.tsx
+++ b/src/pages/index.tsx
@@ -1,15 +1,16 @@
import api from '../api/twitch'
-import Seo from '../components/Seo'
import '../styles/pages/index.css'
+import { shuffle } from '../utils'
import { useStaticQuery, graphql } from 'gatsby'
import { PlusIcon } from '@heroicons/react/solid'
import React, { useState, useEffect } from 'react'
-import usePaginationQuantity from '../hooks/usePaginationQuantity'
+import Seo from '../components/Seo'
import { Layout } from '../layout/Layout'
import { ViewTogglers } from '../components/ViewTogglers'
import { TwitchVideoClip } from '../components/TwitchVideoClip'
import { Skeleton } from '../components/Skeleton'
+import { DelayDisclaimer } from '../components/DelayDisclaimer'
const IndexPage = () => {
const data = useStaticQuery(homeQuery)
@@ -17,15 +18,15 @@ const IndexPage = () => {
const description = data.site.siteMetadata?.description ?? 'Description'
const [view, setView] = useState(false) //grid or list view boolean
- const [cursor, setCursor] = useState(null) //pagination cursor string
+ const [shown, setShown] = useState(9) // how many clips are displayed
const [videos, setVideos] = useState([]) //array of arrays with video links
- const [paginationQuantity] = usePaginationQuantity()
+ const [cursor, setCursor] = useState(null) //pagination cursor string
const requestLoad = () => {
api.getClips((cursor: string, embedUrls: string[]) => {
setCursor(cursor)
setVideos(embedUrls)
- }, paginationQuantity)
+ }, shown)
}
const requestLoadMore = () => {
@@ -34,17 +35,19 @@ const IndexPage = () => {
setCursor(cursor)
setVideos([...videos.concat(embedUrls)])
},
- paginationQuantity,
+ shown,
cursor
)
}
const requestLoadAll = () => {
- api.getAllClips((videos: string[]) => {})
+ api.getAllClips((allEmbedUrls: string[]) => {
+ setVideos(shuffle(allEmbedUrls))
+ })
}
useEffect(() => {
- requestLoad()
+ requestLoadAll()
}, [])
return (
@@ -52,18 +55,19 @@ const IndexPage = () => {
- {videos.map((video: string, videoIdx: number) => (
+ {videos.slice(0, shown).map((video: string, videoIdx: number) => (
))}
{videos.length === 0 &&
- Array(6)
+ Array(shown)
.fill(null)
.map((skeleton, skeletonIdx) => )}
@@ -71,8 +75,8 @@ const IndexPage = () => {