diff options
author | LASER-Yi <[email protected]> | 2021-09-01 00:08:47 +0800 |
---|---|---|
committer | LASER-Yi <[email protected]> | 2021-09-01 00:37:30 +0800 |
commit | 3c790549e0278d6e9263b180d491b2414f6c3734 (patch) | |
tree | d432e270ae882b41071f3014eb791085c8e36ac8 /frontend/src/App/Router.tsx | |
parent | c11483ecc1be444154ef4e638ea107c4fd3674d4 (diff) | |
download | bazarr-3c790549e0278d6e9263b180d491b2414f6c3734.tar.gz bazarr-3c790549e0278d6e9263b180d491b2414f6c3734.zip |
Rewrite router and sidebar
Diffstat (limited to 'frontend/src/App/Router.tsx')
-rw-r--r-- | frontend/src/App/Router.tsx | 71 |
1 files changed, 0 insertions, 71 deletions
diff --git a/frontend/src/App/Router.tsx b/frontend/src/App/Router.tsx deleted file mode 100644 index 626ec6a4d..000000000 --- a/frontend/src/App/Router.tsx +++ /dev/null @@ -1,71 +0,0 @@ -import React, { FunctionComponent, useMemo } from "react"; -import { Redirect, Route, Switch, useHistory } from "react-router-dom"; -import { useDidMount } from "rooks"; -import { useIsRadarrEnabled, useIsSonarrEnabled } from "../@redux/hooks/site"; -import BlacklistRouter from "../Blacklist/Router"; -import DisplayItemRouter from "../DisplayItem/Router"; -import HistoryRouter from "../History/Router"; -import SettingRouter from "../Settings/Router"; -import EmptyPage, { RouterEmptyPath } from "../special-pages/404"; -import SystemRouter from "../System/Router"; -import { ScrollToTop } from "../utilities"; -import WantedRouter from "../Wanted/Router"; - -const Router: FunctionComponent<{ className?: string }> = ({ className }) => { - const sonarr = useIsSonarrEnabled(); - const radarr = useIsRadarrEnabled(); - const redirectPath = useMemo(() => { - if (sonarr) { - return "/series"; - } else if (radarr) { - return "/movies"; - } else { - return "/settings"; - } - }, [sonarr, radarr]); - - const history = useHistory(); - - useDidMount(() => { - history.listen(() => { - // This is a hack to make sure ScrollToTop will be triggered in the next frame (When everything are loaded) - setTimeout(ScrollToTop); - }); - }); - - return ( - <div className={className}> - <Switch> - <Route exact path="/"> - <Redirect exact to={redirectPath}></Redirect> - </Route> - <Route path={["/series", "/movies"]}> - <DisplayItemRouter></DisplayItemRouter> - </Route> - <Route path="/wanted"> - <WantedRouter></WantedRouter> - </Route> - <Route path="/history"> - <HistoryRouter></HistoryRouter> - </Route> - <Route path="/blacklist"> - <BlacklistRouter></BlacklistRouter> - </Route> - <Route path="/settings"> - <SettingRouter></SettingRouter> - </Route> - <Route path="/system"> - <SystemRouter></SystemRouter> - </Route> - <Route exact path={RouterEmptyPath}> - <EmptyPage></EmptyPage> - </Route> - <Route path="*"> - <Redirect to={RouterEmptyPath}></Redirect> - </Route> - </Switch> - </div> - ); -}; - -export default Router; |