// @flow import * as PAGES from 'constants/pages'; import React, { useEffect } from 'react'; import { Route, Redirect, Switch, withRouter } from 'react-router-dom'; import SettingsPage from 'page/settings'; import HelpPage from 'page/help'; import ReportPage from 'page/report'; import AccountPage from 'page/account'; import ShowPage from 'page/show'; import PublishPage from 'page/publish'; import DiscoverPage from 'page/discover'; import RewardsPage from 'page/rewards'; import FileListDownloaded from 'page/fileListDownloaded'; import FileListPublished from 'page/fileListPublished'; import TransactionHistoryPage from 'page/transactionHistory'; import InvitePage from 'page/invite'; import SearchPage from 'page/search'; import LibraryPage from 'page/library'; import WalletPage from 'page/wallet'; import TagsPage from 'page/tags'; import FollowingPage from 'page/following'; import ListBlockedPage from 'page/listBlocked'; import FourOhFourPage from 'page/fourOhFour'; import SignInPage from 'page/signIn'; import SignInVerifyPage from 'page/signInVerify'; import ChannelsPage from 'page/channels'; // Tell the browser we are handling scroll restoration if ('scrollRestoration' in history) { history.scrollRestoration = 'manual'; } type PrivateRouteProps = { component: any, isAuthenticated: boolean, location: { pathname: string }, }; function PrivateRoute(props: PrivateRouteProps) { const { component: Component, isAuthenticated, ...rest } = props; return ( isAuthenticated || !IS_WEB ? ( ) : ( ) } /> ); } type Props = { currentScroll: number, location: { pathname: string, search: string }, isAuthenticated: boolean, }; function AppRouter(props: Props) { const { currentScroll, location: { pathname }, } = props; useEffect(() => { window.scrollTo(0, currentScroll); }, [currentScroll, pathname]); return ( {/* Below need to go at the end to make sure we don't match any of our pages first */} ); } export default withRouter(AppRouter);