on master help sign in
fix logout when inside nested router

fixes: #403 (cherry picked from commit 67485811a258c13277b34a91b0477acbff80868e)

commit148df7745a9e7df70dc7c8e4f42c6b35077bfb51 authorLiam Fitzgerald <liam@urizen.co> dateSat 29 Feb 2020, 10:49 (7 years ago) parent93bfa0c
2 files changed+10−10
src/components/View.js+9−9 src/views/Login.js+1−1
src/components/View.js+9−9
@@ -8,8 +8,6 @@ import MiniBackButton from './MiniBackButton';
88import { useHistory } from 'store/history';
99import NavHeader from './NavHeader';
1010
11−const EXPECT_LOGOUT_WHEN_POPPING_AT_DEPTH = 2;
12−
1311// View is a top-level component that all Views must render to inherit styling
1412function View({
1513 className,
@@ -19,7 +17,7 @@ function View({
1917 pop,
2018 ...rest
2119}) {
22− const { size } = useHistory();
20+ const { reset } = useHistory();
2321 const isMobile = useBreakpoints([true, false, false]);
2422 const shouldInset = inset && !isMobile;
2523
@@ -30,17 +28,19 @@ function View({
3028
3129 const goBack = useCallback(() => pop(), [pop]);
3230
33− const goLogout = useCallback(() => pop(size - 1), [pop, size]);
31+ const goLogout = reset;
3432
35− const showBackButton = size > 1 && !!pop;
36− const backIsLogout = size === EXPECT_LOGOUT_WHEN_POPPING_AT_DEPTH;
33+ const showBackButton = !!pop;
3734
3835 const Header = useCallback(
3936 ({ logout }) => {
4037 return showBackButton ? (
4138 <Flex.Item
4239 as={Flex}
43− className={cn(insetPadding, 'flex-row-r justify-between pb5')}>
40+ className={cn(
41+ insetPadding,
42+ 'flex-row-r justify-between pb5 align-center'
43+ )}>
4444 <Flex.Item
4545 onClick={goLogout}
4646 as="a"
@@ -75,12 +75,12 @@ function View({
7575 col
7676 style={{ width: '48px' }}
7777 className={cn(insetPadding)}>
78− {showBackButton && !backIsLogout && (
78+ {showBackButton && (
7979 <MiniBackButton
8080 hpadding={!isMobile}
8181 vpadding={isMobile}
82− isExit={backIsLogout}
8382 onClick={goBack}
83+ className="mt2"
8484 />
8585 )}
8686 </Flex.Item>
src/views/Login.js+1−1
@@ -59,7 +59,7 @@ export default function Login() {
5959 }, [push, names]);
6060
6161 return (
62− <View pop={pop} inset>
62+ <View inset>
6363 <Grid>
6464 <Grid.Item full as={Crumbs} routes={[{ text: 'Bridge' }]} />
6565 <Grid.Item full as={H4} className="mt4">