mirror of
https://github.com/recloudstream/website.git
synced 2024-08-15 03:18:45 +00:00
uhh maybe now the alerta will work
This commit is contained in:
parent
9bef6357f8
commit
6b75370283
1 changed files with 7 additions and 13 deletions
|
@ -12,20 +12,14 @@ import { IconContext } from "react-icons";
|
||||||
|
|
||||||
const IndexPage = () => {
|
const IndexPage = () => {
|
||||||
const [repos, setRepos] = useState(null);
|
const [repos, setRepos] = useState(null);
|
||||||
const [afterTimeout, setAfterTimeout] = useState(false);
|
const [hadError, setHadError] = useState(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setTimeout(() => {
|
fetch("https://raw.githubusercontent.com/recloudstream/cs-repos/master/repos-db.json", { signal: AbortSignal.timeout(5000) })
|
||||||
setAfterTimeout(true)
|
.catch(err => { setHadError(true) })
|
||||||
}, 5000);
|
|
||||||
fetch("https://raw.githubusercontent.com/recloudstream/cs-repos/master/repos-db.json")
|
|
||||||
.catch(err => {
|
|
||||||
setAfterTimeout(true)
|
|
||||||
})
|
|
||||||
.then(r => r.json())
|
.then(r => r.json())
|
||||||
.then(data => {
|
.then(setRepos)
|
||||||
setRepos(data)
|
.catch(err => { setHadError(true) })
|
||||||
})
|
|
||||||
}, [setRepos])
|
}, [setRepos])
|
||||||
|
|
||||||
return <Layout>
|
return <Layout>
|
||||||
|
@ -47,7 +41,7 @@ const IndexPage = () => {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{(!repos && !afterTimeout) &&
|
{(!repos && !setHadError) &&
|
||||||
<div class="alert shadow-lg w-full mx-10 md:w-2/3 mb-5">
|
<div class="alert shadow-lg w-full mx-10 md:w-2/3 mb-5">
|
||||||
<div>
|
<div>
|
||||||
<span>Fetching data...</span>
|
<span>Fetching data...</span>
|
||||||
|
@ -60,7 +54,7 @@ const IndexPage = () => {
|
||||||
{repos.map((it, index) => <RepoCard repoData={it} key={index} isFirst={index===0}/>)}
|
{repos.map((it, index) => <RepoCard repoData={it} key={index} isFirst={index===0}/>)}
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
{(!repos && afterTimeout) &&
|
{(!repos && setHadError) &&
|
||||||
<div class="alert alert-error shadow-lg w-full mx-10 md:w-2/3 mb-5">
|
<div class="alert alert-error shadow-lg w-full mx-10 md:w-2/3 mb-5">
|
||||||
<div>
|
<div>
|
||||||
<BiErrorAlt />
|
<BiErrorAlt />
|
||||||
|
|
Loading…
Reference in a new issue