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

60 lines
2.1 KiB
TypeScript
Raw Normal View History

2023-04-27 17:04:33 -04:00
import loadable from '@loadable/component';
import { ThemeProvider } from '@mui/material/styles';
2022-10-28 01:09:59 -04:00
import { History } from '@remix-run/router';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
2023-09-30 01:17:37 -04:00
import React from 'react';
2022-10-28 01:09:59 -04:00
2023-09-30 01:17:37 -04:00
import { DASHBOARD_APP_PATHS } from 'apps/dashboard/App';
import AppHeader from 'components/AppHeader';
import Backdrop from 'components/Backdrop';
import { ApiProvider } from 'hooks/useApi';
import { WebConfigProvider } from 'hooks/useWebConfig';
import theme from 'themes/theme';
import { HistoryRouter } from 'components/router/HistoryRouter';
2022-10-28 01:09:59 -04:00
2023-09-20 00:02:26 -04:00
const DashboardApp = loadable(() => import('./apps/dashboard/App'));
const StableAppRouter = loadable(() => import('./apps/stable/AppRouter'));
const RootAppRouter = loadable(() => import('./RootAppRouter'));
2023-04-27 17:04:33 -04:00
const queryClient = new QueryClient();
const RootAppLayout = ({ history }: { history: History }) => {
2023-04-13 00:47:34 +03:00
const layoutMode = localStorage.getItem('layout');
const isExperimentalLayout = layoutMode === 'experimental';
2022-11-18 18:58:11 -05:00
const isNewLayoutPath = Object.values(DASHBOARD_APP_PATHS)
.some(path => window.location.pathname.startsWith(`/${path}`));
2022-10-28 01:09:59 -04:00
return (
<>
<Backdrop />
<AppHeader isHidden={isExperimentalLayout || isNewLayoutPath} />
{isExperimentalLayout ?
<RootAppRouter history={history} /> :
<StableAppRouter history={history} />
}
2023-09-20 00:02:26 -04:00
<HistoryRouter history={history}>
<DashboardApp />
</HistoryRouter>
</>
2022-10-28 01:09:59 -04:00
);
};
const RootApp = ({ history }: { history: History }) => (
<QueryClientProvider client={queryClient}>
<ApiProvider>
<WebConfigProvider>
<ThemeProvider theme={theme}>
<RootAppLayout history={history} />
</ThemeProvider>
</WebConfigProvider>
</ApiProvider>
<ReactQueryDevtools initialIsOpen={false} />
</QueryClientProvider>
);
2023-04-27 17:04:33 -04:00
export default RootApp;