on master help sign in
hack in activate routing

very bad hack(tm) but pointless overengineering to do anything else should move to an actual router lib.

commite02d105b98ebebbf65b24ec2b9ddfb04338f1723 authorLiam Fitzgerald <liam@urizen.co> dateSat 7 Mar 2020, 12:34 (7 years ago) parent853a244
2 files changed+11−2
src/Bridge.js+3−1 src/views/Activate.js+8−1
src/Bridge.js+3−1
@@ -42,6 +42,8 @@ function useInitialRoutes() {
4242 const [hasDisclaimed] = useHasDisclaimed();
4343 const hasImpliedTicket = !!useImpliedTicket();
4444
45+ const isActivateUrl = window.location.pathname === '/activate';
46+
4547 if (IS_STUBBED) {
4648 return [
4749 { key: ROUTE_NAMES.LOGIN },
@@ -50,7 +52,7 @@ function useInitialRoutes() {
5052 ];
5153 }
5254
53− if (hasImpliedTicket) {
55+ if (hasImpliedTicket || isActivateUrl) {
5456 return [{ key: ROUTE_NAMES.ACTIVATE }];
5557 }
5658
src/views/Activate.js+8−1
@@ -1,4 +1,4 @@
1−import React from 'react';
1+import React, { useEffect } from 'react';
22
33import useRouter from 'lib/useRouter';
44import { LocalRouterProvider } from 'lib/LocalRouter';
@@ -30,6 +30,13 @@ export default function Activate() {
3030 initialRoutes: [{ key: NAMES.CODE }],
3131 });
3232
33+ useEffect(() => {
34+ // remove potential /activate path on unmount
35+ return () => {
36+ window.history.replaceState(null, null, '');
37+ };
38+ }, []);
39+
3340 // when we know the derived point, ensure we have the data to display it
3441 useSyncKnownPoints(
3542 [state.derivedPoint.getOrElse(null)].filter(p => p !== null)