forked from Asvarox/allkaraoke
-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
95 lines (88 loc) · 4.25 KB
/
App.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import { ErrorBoundary, withProfiler } from '@sentry/react';
import { KeyboardHelpProvider } from 'routes/KeyboardHelp/Context';
import RemoteMic from 'routes/RemoteMic/RemoteMic';
import Settings from 'routes/Settings/Settings';
import { Route, Router, Switch } from 'wouter';
import Convert from './routes/Convert/Convert';
import Edit from './routes/Edit/Edit';
import Jukebox from './routes/Jukebox/Jukebox';
import SelectInput from './routes/SelectInput/SelectInput';
import { Theme, ThemeProvider, createTheme } from '@mui/material/styles';
import { ErrorFallback } from 'modules/Elements/ErrorFallback';
import LayoutWithBackgroundProvider from 'modules/Elements/LayoutWithBackground';
import PageLoader from 'modules/Elements/PageLoader';
import { Suspense, lazy, useMemo } from 'react';
import GetSongsBPMs from 'routes/Edit/GetSongsBPMs';
import ExcludeLanguages from 'routes/ExcludeLanguages/ExcludeLanguages';
import Game from 'routes/Game/Game';
import LandingPage from 'routes/LandingPage/LandingPage';
import ManageSongs from 'routes/ManageSongs/ManageSongs';
import QuickSetup from 'routes/QuickSetup/QuickSetup';
import RemoteMicSettings from 'routes/Settings/RemoteMicSettings';
import { GraphicSetting, MobilePhoneModeSetting, useSettingValue } from 'routes/Settings/SettingsState';
import SocialMediaElements from 'routes/SocialMediaElements/SocialMediaElements';
import Welcome from 'routes/Welcome/Welcome';
import routePaths from 'routes/routePaths';
const LazySongList = lazy(() =>
import('routes/ManageSongs/SongManagement').then((modules) => ({ default: modules.SongList })),
);
// Commenting this out as there are many failed to fetch errors coming from Googlebot
// // This is a hack to preload the game scene so that it's ready when the user clicks on the game button
// // without increasing initial load time. Vite doesn't support prefetch yet
// // https://github.com/vitejs/vite/issues/10600
// const prefetchGame = import('./routes/Game/Game');
// const LazyGame = lazy(() => prefetchGame);
function App() {
const [mobilePhoneMode] = useSettingValue(MobilePhoneModeSetting);
const [graphicSetting] = useSettingValue(GraphicSetting);
const theme = useMemo<Theme>(
() =>
createTheme({
graphicSetting,
}),
[graphicSetting],
);
return (
<ThemeProvider theme={theme}>
<ErrorBoundary fallback={ErrorFallback}>
<LayoutWithBackgroundProvider>
<KeyboardHelpProvider>
<Router base={import.meta.env.BASE_URL}>
<Switch>
<Route path={routePaths.QUICK_SETUP} component={QuickSetup} />
<Route path={routePaths.MENU} component={Welcome} />
<Route path={routePaths.EXCLUDE_LANGUAGES} component={ExcludeLanguages} />
<Route path={routePaths.JUKEBOX} component={Jukebox} />
<Route path={routePaths.GAME}>
{/*<Suspense fallback={<PageLoader />}><LazyGame /></Suspense>*/}
<Game />
</Route>
<Route path={routePaths.SELECT_INPUT} component={SelectInput} />
<Route path={routePaths.SETTINGS} component={Settings} />
<Route path={routePaths.SETTINGS_REMOTE_MICS} component={RemoteMicSettings} />
<Route path={routePaths.REMOTE_MIC} component={RemoteMic} />
<Route path={routePaths.MANAGE_SONGS} component={ManageSongs} />
<Route path="social-media-elements" component={SocialMediaElements} />
<Route path={routePaths.CONVERT} component={() => <Convert />} />
<Route
path={routePaths.EDIT_SONGS_LIST}
component={() => (
<Suspense fallback={<PageLoader />}>
<LazySongList />
</Suspense>
)}
/>
<Route path="edit/get-songs-bpms" component={GetSongsBPMs} />
<Route path={routePaths.EDIT_SONG}>
<Edit />
</Route>
<Route path={routePaths.INDEX} component={LandingPage} />
</Switch>
</Router>
</KeyboardHelpProvider>
</LayoutWithBackgroundProvider>
</ErrorBoundary>
</ThemeProvider>
);
}
export default withProfiler(App);