Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/components/dashboard/src/app/AppLoading.tsx
2499 views
1
/**
2
* Copyright (c) 2022 Gitpod GmbH. All rights reserved.
3
* Licensed under the GNU Affero General Public License (AGPL).
4
* See License.AGPL.txt in the project root for license information.
5
*/
6
7
import { FunctionComponent, useEffect, useState } from "react";
8
import { Heading3, Subheading } from "../components/typography/headings";
9
import { Delayed } from "@podkit/loading/Delayed";
10
import { ProductLogo } from "../components/ProductLogo";
11
12
function useDelay(wait: number) {
13
const [done, setDone] = useState(false);
14
useEffect(() => {
15
const timeout = setTimeout(() => setDone(true), wait);
16
return () => clearTimeout(timeout);
17
// eslint-disable-next-line react-hooks/exhaustive-deps
18
}, [wait]);
19
return done;
20
}
21
22
export const AppLoading: FunctionComponent = () => {
23
const done = useDelay(8000);
24
const connectionProblems = useDelay(25000);
25
return (
26
<Delayed wait={3000}>
27
<div className="flex flex-col justify-center items-center w-full h-screen space-y-4">
28
<ProductLogo className={"h-16 flex-shrink-0 animate-fade-in"} />
29
{connectionProblems ? (
30
<Heading3 className={done ? "" : "invisible"}>This is taking longer than it should</Heading3>
31
) : (
32
<Heading3 className={done ? "animate-fade-in" : "invisible"}>
33
Just getting a few more things ready
34
</Heading3>
35
)}
36
{connectionProblems ? (
37
<Subheading className={done ? "max-w-xl text-center" : "invisible"}>
38
It seems like you are having connection issues. Please check your network connection. Sometimes
39
this problem can also be caused by a slow browser with too many tabs and/or extensions.
40
</Subheading>
41
) : (
42
<Subheading className={done ? "animate-fade-in" : "invisible"}>hang in there...</Subheading>
43
)}
44
</div>
45
</Delayed>
46
);
47
};
48
49