2020-08-14 13:27:41 +02:00
|
|
|
import { t } from "../i18n";
|
2022-04-19 19:08:13 +02:00
|
|
|
import { useState, useEffect } from "react";
|
|
|
|
import Spinner from "./Spinner";
|
|
|
|
|
|
|
|
export const LoadingMessage: React.FC<{ delay?: number }> = ({ delay }) => {
|
|
|
|
const [isWaiting, setIsWaiting] = useState(!!delay);
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
if (!delay) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const timer = setTimeout(() => {
|
|
|
|
setIsWaiting(false);
|
|
|
|
}, delay);
|
|
|
|
return () => clearTimeout(timer);
|
|
|
|
}, [delay]);
|
|
|
|
|
|
|
|
if (isWaiting) {
|
|
|
|
return null;
|
|
|
|
}
|
2020-03-26 18:28:26 +01:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div className="LoadingMessage">
|
2022-04-19 19:08:13 +02:00
|
|
|
<div>
|
|
|
|
<Spinner />
|
|
|
|
</div>
|
|
|
|
<div className="LoadingMessage-text">{t("labels.loadingScene")}</div>
|
2020-03-26 18:28:26 +01:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|