Compare commits
2 Commits
searchDefa
...
wip/react-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9299bdb781 | ||
|
|
339fbb491f |
@@ -54,6 +54,7 @@
|
||||
"express": "^4.17.1",
|
||||
"if-env": "^1.0.4",
|
||||
"react-datetime-picker": "^3.2.1",
|
||||
"react-top-loading-bar": "^2.0.1",
|
||||
"remove-markdown": "^0.3.0",
|
||||
"tempy": "^0.6.0",
|
||||
"videojs-logo": "^2.1.4"
|
||||
|
||||
@@ -17,6 +17,7 @@ import usePrevious from 'effects/use-previous';
|
||||
import Nag from 'component/common/nag';
|
||||
import REWARDS from 'rewards';
|
||||
import usePersistedState from 'effects/use-persisted-state';
|
||||
import LoadingBar from 'react-top-loading-bar';
|
||||
import FileDrop from 'component/fileDrop';
|
||||
import NagContinueFirstRun from 'component/nagContinueFirstRun';
|
||||
import Spinner from 'component/spinner';
|
||||
@@ -120,6 +121,7 @@ function App(props: Props) {
|
||||
} = props;
|
||||
|
||||
const appRef = useRef();
|
||||
const loadingBarRef = useRef();
|
||||
const isEnhancedLayout = useKonamiListener();
|
||||
const [hasSignedIn, setHasSignedIn] = useState(false);
|
||||
const [readyForSync, setReadyForSync] = useState(false);
|
||||
@@ -381,7 +383,8 @@ function App(props: Props) {
|
||||
/>
|
||||
) : (
|
||||
<React.Fragment>
|
||||
<Router />
|
||||
<Router loadingBar={loadingBarRef} />
|
||||
{<LoadingBar ref={loadingBarRef} loaderSpeed={10} transitionTime={10} />}
|
||||
<ModalRouter />
|
||||
<FileDrop />
|
||||
<FileRenderFloating />
|
||||
|
||||
@@ -89,6 +89,7 @@ type Props = {
|
||||
setReferrer: (string) => void,
|
||||
hasUnclaimedRefereeReward: boolean,
|
||||
homepageData: any,
|
||||
loadingBar?: any,
|
||||
};
|
||||
|
||||
type PrivateRouteProps = Props & {
|
||||
@@ -128,6 +129,8 @@ function AppRouter(props: Props) {
|
||||
hasUnclaimedRefereeReward,
|
||||
setReferrer,
|
||||
homepageData,
|
||||
loadingBar,
|
||||
location,
|
||||
} = props;
|
||||
const { entries, listen, action: historyAction } = history;
|
||||
const entryIndex = history.index;
|
||||
@@ -139,6 +142,20 @@ function AppRouter(props: Props) {
|
||||
(potentialRoute: any) => potentialRoute && potentialRoute.route
|
||||
);
|
||||
|
||||
console.log('router:', props);
|
||||
const isPathResolved = history.location.pathname === location.pathname;
|
||||
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
if (history.action === 'POP' || history.action === 'PUSH') {
|
||||
if (loadingBar && loadingBar.current) {
|
||||
console.log('start');
|
||||
loadingBar.current.staticStart();
|
||||
}
|
||||
}
|
||||
};
|
||||
}, [history.action, history.location]);
|
||||
|
||||
// For people arriving at settings page from deeplinks, know whether they can "go back"
|
||||
useEffect(() => {
|
||||
const unlisten = listen((location, action) => {
|
||||
@@ -198,6 +215,47 @@ function AppRouter(props: Props) {
|
||||
}
|
||||
}, [currentScroll, pathname, search, hash, resetScroll, hasLinkedCommentInUrl, historyAction]);
|
||||
|
||||
// useEffect(() => {
|
||||
// if (loadingBar && loadingBar.current) {
|
||||
// console.log('hasNavigated:', hasNavigated);
|
||||
// if (hasNavigated) {
|
||||
// loadingBar.current.continuousStart();
|
||||
// } else {loadingBar.current.complete();
|
||||
// }
|
||||
// }
|
||||
// }, [hasNavigated]);
|
||||
|
||||
// useEffect(() => {
|
||||
// console.log('isPathResolved:', isPathResolved);
|
||||
// if (loadingBar && loadingBar.current) {
|
||||
// if (isPathResolved) {
|
||||
// console.log(' stop');
|
||||
// loadingBar.current.complete();
|
||||
// } else {
|
||||
// console.log(' start');
|
||||
// loadingBar.current.continuousStart();
|
||||
// }
|
||||
// }
|
||||
// }, [isPathResolved]);
|
||||
|
||||
// useEffect(() => {
|
||||
// console.log('isPathResolved:', isPathResolved);
|
||||
// if (loadingBar && loadingBar.current) {
|
||||
// if (isPathResolved) {
|
||||
// console.log(' stop');
|
||||
// loadingBar.current.complete();
|
||||
// }
|
||||
// }
|
||||
// }, [isPathResolved]);
|
||||
|
||||
useEffect(() => {
|
||||
console.log('router done');
|
||||
if (isPathResolved && loadingBar && loadingBar.current) {
|
||||
console.log('stop');
|
||||
loadingBar.current.complete();
|
||||
}
|
||||
});
|
||||
|
||||
// react-router doesn't decode pathanmes before doing the route matching check
|
||||
// We have to redirect here because if we redirect on the server, it might get encoded again
|
||||
// in the browser causing a redirect loop
|
||||
|
||||
@@ -9450,6 +9450,11 @@ react-time-picker@^4.2.0:
|
||||
react-fit "^1.0.3"
|
||||
update-input-width "^1.1.1"
|
||||
|
||||
react-top-loading-bar@^2.0.1:
|
||||
version "2.0.1"
|
||||
resolved "https://registry.yarnpkg.com/react-top-loading-bar/-/react-top-loading-bar-2.0.1.tgz#c8805ad9c1068766fdd3cadd414e67cfdf1878e9"
|
||||
integrity sha512-wkRlK9Rte4TU817GDcjlsCoDOxrrnvsNvK609FKyio0EIrmmqjQDz5DB8HbN88CHNZBy5Lh/OBALc03ioWFPuQ==
|
||||
|
||||
react@^16.8.2:
|
||||
version "16.13.0"
|
||||
resolved "https://registry.yarnpkg.com/react/-/react-16.13.0.tgz#d046eabcdf64e457bbeed1e792e235e1b9934cf7"
|
||||
|
||||
Reference in New Issue
Block a user