on master help sign in
Display disclaimer only on first run
1333ce5Fang
src/Bridge.js+4−1
@@ -12,6 +12,7 @@ import { ROUTES } from 'lib/router';
12import { NETWORK_TYPES } from 'lib/network';
12import { NETWORK_TYPES } from 'lib/network';
13import { walletFromMnemonic } from 'lib/wallet';
13import { walletFromMnemonic } from 'lib/wallet';
14import { isDevelopment } from 'lib/flags';
14import { isDevelopment } from 'lib/flags';
15+import { hasDisclaimed } from 'lib/disclaimerCookie';
15
16
16import 'style/index.scss';
17import 'style/index.scss';
17
18
@@ -24,7 +25,9 @@ const SHOULD_STUB_LOCAL = process.env.REACT_APP_STUB_LOCAL === 'true';
24const IS_STUBBED = isDevelopment && SHOULD_STUB_LOCAL;
25const IS_STUBBED = isDevelopment && SHOULD_STUB_LOCAL;
25const INITIAL_ROUTES = IS_STUBBED
26const INITIAL_ROUTES = IS_STUBBED
26 ? [{ key: ROUTE_NAMES.LANDING }, { key: ROUTE_NAMES.LOGIN }]
27 ? [{ key: ROUTE_NAMES.LANDING }, { key: ROUTE_NAMES.LOGIN }]
28+ : hasDisclaimed()
27− : [{ key: ROUTE_NAMES.LANDING }];
29+ ? [{ key: ROUTE_NAMES.LANDING }]
30+ : [{ key: ROUTE_NAMES.DISCLAIMER }];
28
31
29const INITIAL_WALLET = IS_STUBBED
32const INITIAL_WALLET = IS_STUBBED
30 ? walletFromMnemonic(
33 ? walletFromMnemonic(
src/lib/disclaimerCookie.jsnew file+9
@@ -0,0 +1,9 @@
1+const COOKIE_ID = 'bridge_disclaimed';
2+
3+export const hasDisclaimed = () => {
4+ return document.cookie.includes(COOKIE_ID);
5+};
6+
7+export const setDisclaimerCookie = () => {
8+ document.cookie = COOKIE_ID;
9+};
src/lib/routeNames.js+1
@@ -1,5 +1,6 @@
1export const ROUTE_NAMES = {
1export const ROUTE_NAMES = {
2 DEFAULT: Symbol('DEFAULT'),
2 DEFAULT: Symbol('DEFAULT'),
3+ DISCLAIMER: Symbol('DISCLAIMER'),
3 //
4 //
4 ACTIVATE: Symbol('ACTIVATE'),
5 ACTIVATE: Symbol('ACTIVATE'),
5 INVITE_TRANSACTIONS: Symbol('INVITE_TRANSACTIONS'),
6 INVITE_TRANSACTIONS: Symbol('INVITE_TRANSACTIONS'),
src/lib/router.js+2
@@ -1,4 +1,5 @@
1import Landing from '../views/Landing';
1import Landing from '../views/Landing';
2+import Disclaimer from '../views/Disclaimer';
2import Login from '../views/Login.js';
3import Login from '../views/Login.js';
3import InvitesManage from '../views/InvitesManage.js';
4import InvitesManage from '../views/InvitesManage.js';
4import Admin from '../views/Admin';
5import Admin from '../views/Admin';
@@ -28,6 +29,7 @@ import { ROUTE_NAMES } from './routeNames';
28
29
29export const ROUTES = {
30export const ROUTES = {
30 [ROUTE_NAMES.LANDING]: Landing,
31 [ROUTE_NAMES.LANDING]: Landing,
32+ [ROUTE_NAMES.DISCLAIMER]: Disclaimer,
31 [ROUTE_NAMES.ACTIVATE]: Activate,
33 [ROUTE_NAMES.ACTIVATE]: Activate,
32 [ROUTE_NAMES.INVITE]: Invite,
34 [ROUTE_NAMES.INVITE]: Invite,
33 [ROUTE_NAMES.INVITES_MANAGE]: InvitesManage,
35 [ROUTE_NAMES.INVITES_MANAGE]: InvitesManage,
src/views/Activate.js−2
@@ -5,7 +5,6 @@ import useRouter from 'lib/useRouter';
5import { ActivateFlowProvider } from './Activate/ActivateFlow';
5import { ActivateFlowProvider } from './Activate/ActivateFlow';
6import useActivateFlowState from './Activate/useActivateFlowState';
6import useActivateFlowState from './Activate/useActivateFlowState';
7import ActivateCode from './Activate/ActivateCode';
7import ActivateCode from './Activate/ActivateCode';
8−import ActivateDisclaimer from './Activate/ActivateDisclaimer';
9import { LocalRouterProvider } from 'lib/LocalRouter';
8import { LocalRouterProvider } from 'lib/LocalRouter';
10import ActivatePassport from './Activate/ActivatePassport';
9import ActivatePassport from './Activate/ActivatePassport';
11
10
@@ -17,7 +16,6 @@ const NAMES = {
17
16
18const VIEWS = {
17const VIEWS = {
19 [NAMES.CODE]: ActivateCode,
18 [NAMES.CODE]: ActivateCode,
20− [NAMES.DISCLAIMER]: ActivateDisclaimer,
21 [NAMES.PASSPORT]: ActivatePassport,
19 [NAMES.PASSPORT]: ActivatePassport,
22};
20};
23
21
src/views/Activate/ActivateCode.js+2−5
@@ -48,10 +48,7 @@ export default function ActivateCode() {
48 const goToLogin = useCallback(() => history.popAndPush(ROUTE_NAMES.LOGIN), [
48 const goToLogin = useCallback(() => history.popAndPush(ROUTE_NAMES.LOGIN), [
49 history,
49 history,
50 ]);
50 ]);
51− const goToDisclaimer = useCallback(() => push(names.DISCLAIMER), [
51+ const goToPassport = useCallback(() => push(names.PASSPORT), [names, push]);
52− names,
53− push,
54− ]);
55
52
56 const pass = derivedWallet.matchWith({
53 const pass = derivedWallet.matchWith({
57 Nothing: () => false,
54 Nothing: () => false,
@@ -142,7 +139,7 @@ export default function ActivateCode() {
142 className="mt4"
139 className="mt4"
143 disabled={!pass || deriving}
140 disabled={!pass || deriving}
144 accessory={deriving ? <Blinky /> : undefined}
141 accessory={deriving ? <Blinky /> : undefined}
145− onClick={goToDisclaimer}
142+ onClick={goToPassport}
146 solid
143 solid
147 full>
144 full>
148 {deriving && 'Deriving...'}
145 {deriving && 'Deriving...'}
src/views/Activate/ActivateDisclaimer.js → src/views/Disclaimer.jsrenamed+7−3
@@ -3,7 +3,8 @@ import cn from 'classnames';
3import { Grid, H3, B, Text, CheckboxInput } from 'indigo-react';
3import { Grid, H3, B, Text, CheckboxInput } from 'indigo-react';
4
4
5import { useCheckboxInput } from 'lib/useInputs';
5import { useCheckboxInput } from 'lib/useInputs';
6−import { useLocalRouter } from 'lib/LocalRouter';
6+import { useHistory } from 'store/history';
7+import { setDisclaimerCookie } from 'lib/disclaimerCookie';
7
8
8import View from 'components/View';
9import View from 'components/View';
9import { ForwardButton } from 'components/Buttons';
10import { ForwardButton } from 'components/Buttons';
@@ -12,13 +13,16 @@ import WarningBox from 'components/WarningBox';
12const TEXT_STYLE = 'f5';
13const TEXT_STYLE = 'f5';
13
14
14export default function ActivateDisclaimer() {
15export default function ActivateDisclaimer() {
15− const { push, names } = useLocalRouter();
16+ const { popAndPush, names } = useHistory();
16 const [understoodInput, { data: isUnderstood }] = useCheckboxInput({
17 const [understoodInput, { data: isUnderstood }] = useCheckboxInput({
17 name: 'checkbox',
18 name: 'checkbox',
18 label: 'I acknowledge and understand these rights',
19 label: 'I acknowledge and understand these rights',
19 });
20 });
20
21
21− const goToPassport = useCallback(() => push(names.PASSPORT), [push, names]);
22+ const goToPassport = useCallback(() => {
23+ setDisclaimerCookie();
24+ popAndPush(names.LANDING);
25+ }, [popAndPush, names]);
22
26
23 return (
27 return (
24 <View>
28 <View>