2022-08-26 13:46:21 +00:00
import React , { useEffect , useState } from "react"
import Layout from "../components/layout"
import RepoCard from "../components/cards/repo"
2022-09-18 10:07:07 +00:00
import AdbConnect from "../components/adbconnect"
2022-08-26 15:30:19 +00:00
import bgImage from "../media/phones.png"
2022-08-26 13:46:21 +00:00
2022-09-01 07:56:43 +00:00
import { TiWarning } from "react-icons/ti" ;
2022-10-01 18:16:34 +00:00
import { BiErrorAlt } from "react-icons/bi" ;
2022-09-19 07:36:53 +00:00
import { GoVerified } from "react-icons/go" ;
2022-09-22 09:39:46 +00:00
import { IconContext } from "react-icons" ;
2022-09-01 07:56:43 +00:00
2022-08-26 13:46:21 +00:00
const IndexPage = ( ) => {
2022-10-01 18:16:34 +00:00
const [ repos , setRepos ] = useState ( null ) ;
2022-10-02 19:37:57 +00:00
const [ hadError , setHadError ] = useState ( false ) ;
2022-08-26 13:46:21 +00:00
useEffect ( ( ) => {
2022-10-02 19:37:57 +00:00
fetch ( "https://raw.githubusercontent.com/recloudstream/cs-repos/master/repos-db.json" , { signal : AbortSignal . timeout ( 5000 ) } )
. catch ( err => { setHadError ( true ) } )
2022-08-26 13:46:21 +00:00
. then ( r => r . json ( ) )
2022-10-02 19:37:57 +00:00
. then ( setRepos )
. catch ( err => { setHadError ( true ) } )
2022-08-26 13:46:21 +00:00
} , [ setRepos ] )
return < Layout >
< div className = "flex items-center w-full flex-col" >
2022-09-01 07:56:43 +00:00
< div className = "alert alert-warning shadow-lg w-full mx-10 md:w-2/3 mb-5" >
< div >
< TiWarning className = "stroke-current flex-shrink-0 h-6 w-6" / >
< div >
< h3 className = "font-bold text-xl" > Keep in mind that the extensions can execute arbitrary code inside the app . < / h 3 >
2022-09-19 07:36:53 +00:00
< span className = "text-xs" >
This means you should treat them with the same level of scrutiny you treat any apps . Extensions can also read all of the Cloudstream ' s data .
< / s p a n >
< br / >
2022-09-22 09:39:46 +00:00
< IconContext . Provider value = { { className : 'inline-block' } } >
< span className = "text-xs" >
Repos with a < GoVerified class = "stroke-current flex-shrink-0 mx-1" / > are constantly audited by the app developers so you can probably trust them .
< / s p a n >
< / I c o n C o n t e x t . P r o v i d e r >
2022-09-01 07:56:43 +00:00
< / d i v >
< / d i v >
< / d i v >
2022-10-02 19:37:57 +00:00
{ ( ! repos && ! setHadError ) &&
2022-10-01 18:30:02 +00:00
< div class = "alert shadow-lg w-full mx-10 md:w-2/3 mb-5" >
2022-10-01 18:16:34 +00:00
< div >
< span > Fetching data ... < / s p a n >
< / d i v >
< / d i v >
}
2022-08-26 13:46:21 +00:00
{ repos &&
2022-10-01 18:16:34 +00:00
< >
< AdbConnect / >
{ repos . map ( ( it , index ) => < RepoCard repoData = { it } key = { index } isFirst = { index === 0 } / > ) }
< / >
}
2022-10-02 19:37:57 +00:00
{ ( ! repos && setHadError ) &&
2022-10-01 18:30:02 +00:00
< div class = "alert alert-error shadow-lg w-full mx-10 md:w-2/3 mb-5" >
2022-10-01 18:16:34 +00:00
< div >
< BiErrorAlt / >
< div >
2022-10-01 18:37:51 +00:00
< h3 class = "font-bold" > Failed to connect to GitHub servers . < / h 3 >
2022-10-01 18:16:34 +00:00
< div class = "text-xs" > GitHub has been a target of < a href = "https://en.wikipedia.org/wiki/Censorship_of_GitHub" className = "link" target = "_blank" > censorship < /a> in some countries. <br/ > Please try changing your < a href = "https://1.1.1.1/dns/" className = "link" target = "_blank" > DNS server < / a > o r t r y u s i n g a V P N . < / d i v >
< / d i v >
< / d i v >
< / d i v >
2022-08-26 13:46:21 +00:00
}
< / d i v >
< / L a y o u t >
}
export function Head ( ) {
return (
2022-08-26 15:30:19 +00:00
< >
< title > Cloudstream Repositories < / t i t l e >
< meta property = "og:title" content = "Cloudstream Repositories" / >
< meta property = "og:description" content = "Cloudstream is an Android app for streaming and downloading Movies, TV-Series and Anime." / >
< meta property = "og:image" content = { bgImage } / >
< meta property = "og:image:type" content = "image/png" / >
2022-08-26 15:40:16 +00:00
< meta name = "twitter:card" content = "summary_large_image" / >
2022-08-26 15:30:19 +00:00
< / >
2022-08-26 13:46:21 +00:00
)
}
export default IndexPage