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:
parent
e0bc17a018
commit
5c080f4fc5
2 changed files with 19 additions and 11 deletions
|
@ -3,7 +3,7 @@ import { Outlet, useNavigate } from 'react-router-dom';
|
|||
|
||||
import alert from './alert';
|
||||
import { appRouter } from './appRouter';
|
||||
import loading from './loading/loading';
|
||||
import Loading from './loading/Loading';
|
||||
import ServerConnections from './ServerConnections';
|
||||
import globalize from '../scripts/globalize';
|
||||
|
||||
|
@ -152,17 +152,8 @@ const ConnectionRequired: FunctionComponent<ConnectionRequiredProps> = ({
|
|||
validateConnection();
|
||||
}, [ isAdminRequired, isUserRequired, navigate ]);
|
||||
|
||||
// Show/hide the loading indicator
|
||||
useEffect(() => {
|
||||
if (isLoading) {
|
||||
loading.show();
|
||||
} else {
|
||||
loading.hide();
|
||||
}
|
||||
}, [ isLoading ]);
|
||||
|
||||
if (isLoading) {
|
||||
return null;
|
||||
return <Loading />;
|
||||
}
|
||||
|
||||
return <Outlet />;
|
||||
|
|
17
src/components/loading/Loading.tsx
Normal file
17
src/components/loading/Loading.tsx
Normal 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;
|
Loading…
Add table
Add a link
Reference in a new issue