mirror of
https://github.com/LBRYFoundation/lbry-desktop.git
synced 2025-08-23 17:47:24 +00:00
--- for fun
This commit is contained in:
parent
339fbb491f
commit
9299bdb781
2 changed files with 62 additions and 1 deletions
|
@ -17,6 +17,7 @@ import usePrevious from 'effects/use-previous';
|
||||||
import Nag from 'component/common/nag';
|
import Nag from 'component/common/nag';
|
||||||
import REWARDS from 'rewards';
|
import REWARDS from 'rewards';
|
||||||
import usePersistedState from 'effects/use-persisted-state';
|
import usePersistedState from 'effects/use-persisted-state';
|
||||||
|
import LoadingBar from 'react-top-loading-bar';
|
||||||
import FileDrop from 'component/fileDrop';
|
import FileDrop from 'component/fileDrop';
|
||||||
import NagContinueFirstRun from 'component/nagContinueFirstRun';
|
import NagContinueFirstRun from 'component/nagContinueFirstRun';
|
||||||
import Spinner from 'component/spinner';
|
import Spinner from 'component/spinner';
|
||||||
|
@ -120,6 +121,7 @@ function App(props: Props) {
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
const appRef = useRef();
|
const appRef = useRef();
|
||||||
|
const loadingBarRef = useRef();
|
||||||
const isEnhancedLayout = useKonamiListener();
|
const isEnhancedLayout = useKonamiListener();
|
||||||
const [hasSignedIn, setHasSignedIn] = useState(false);
|
const [hasSignedIn, setHasSignedIn] = useState(false);
|
||||||
const [readyForSync, setReadyForSync] = useState(false);
|
const [readyForSync, setReadyForSync] = useState(false);
|
||||||
|
@ -381,7 +383,8 @@ function App(props: Props) {
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
<Router />
|
<Router loadingBar={loadingBarRef} />
|
||||||
|
{<LoadingBar ref={loadingBarRef} loaderSpeed={10} transitionTime={10} />}
|
||||||
<ModalRouter />
|
<ModalRouter />
|
||||||
<FileDrop />
|
<FileDrop />
|
||||||
<FileRenderFloating />
|
<FileRenderFloating />
|
||||||
|
|
|
@ -89,6 +89,7 @@ type Props = {
|
||||||
setReferrer: (string) => void,
|
setReferrer: (string) => void,
|
||||||
hasUnclaimedRefereeReward: boolean,
|
hasUnclaimedRefereeReward: boolean,
|
||||||
homepageData: any,
|
homepageData: any,
|
||||||
|
loadingBar?: any,
|
||||||
};
|
};
|
||||||
|
|
||||||
type PrivateRouteProps = Props & {
|
type PrivateRouteProps = Props & {
|
||||||
|
@ -128,6 +129,8 @@ function AppRouter(props: Props) {
|
||||||
hasUnclaimedRefereeReward,
|
hasUnclaimedRefereeReward,
|
||||||
setReferrer,
|
setReferrer,
|
||||||
homepageData,
|
homepageData,
|
||||||
|
loadingBar,
|
||||||
|
location,
|
||||||
} = props;
|
} = props;
|
||||||
const { entries, listen, action: historyAction } = history;
|
const { entries, listen, action: historyAction } = history;
|
||||||
const entryIndex = history.index;
|
const entryIndex = history.index;
|
||||||
|
@ -139,6 +142,20 @@ function AppRouter(props: Props) {
|
||||||
(potentialRoute: any) => potentialRoute && potentialRoute.route
|
(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"
|
// For people arriving at settings page from deeplinks, know whether they can "go back"
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const unlisten = listen((location, action) => {
|
const unlisten = listen((location, action) => {
|
||||||
|
@ -198,6 +215,47 @@ function AppRouter(props: Props) {
|
||||||
}
|
}
|
||||||
}, [currentScroll, pathname, search, hash, resetScroll, hasLinkedCommentInUrl, historyAction]);
|
}, [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
|
// 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
|
// We have to redirect here because if we redirect on the server, it might get encoded again
|
||||||
// in the browser causing a redirect loop
|
// in the browser causing a redirect loop
|
||||||
|
|
Loading…
Add table
Reference in a new issue