1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

Add react loading component

This commit is contained in:
Bill Thornton 2022-10-31 02:05:51 -04:00
parent e0bc17a018
commit 5c080f4fc5
2 changed files with 19 additions and 11 deletions

View file

@ -3,7 +3,7 @@ import { Outlet, useNavigate } from 'react-router-dom';
import alert from './alert'; import alert from './alert';
import { appRouter } from './appRouter'; import { appRouter } from './appRouter';
import loading from './loading/loading'; import Loading from './loading/Loading';
import ServerConnections from './ServerConnections'; import ServerConnections from './ServerConnections';
import globalize from '../scripts/globalize'; import globalize from '../scripts/globalize';
@ -152,17 +152,8 @@ const ConnectionRequired: FunctionComponent<ConnectionRequiredProps> = ({
validateConnection(); validateConnection();
}, [ isAdminRequired, isUserRequired, navigate ]); }, [ isAdminRequired, isUserRequired, navigate ]);
// Show/hide the loading indicator
useEffect(() => {
if (isLoading) {
loading.show();
} else {
loading.hide();
}
}, [ isLoading ]);
if (isLoading) { if (isLoading) {
return null; return <Loading />;
} }
return <Outlet />; return <Outlet />;

View file

@ -0,0 +1,17 @@
import React, { FunctionComponent, useEffect } from 'react';
import loading from './loading';
const Loading: FunctionComponent = () => {
useEffect(() => {
loading.show();
return () => {
loading.hide();
};
}, []);
return <></>;
};
export default Loading;