From 600d3565f7fb3a593163797ee2086386af88d9fa Mon Sep 17 00:00:00 2001 From: Szymon Lesisz Date: Wed, 10 Oct 2018 12:12:56 +0200 Subject: [PATCH] fix redirection to /bridge from landingpage - allows to redirect from / to /bridge route - fix current bridge version if transport is webusb - RouterActions optionally verifies if requested url has "landing" prefix in ./support/routes --- src/actions/RouterActions.js | 13 ++++++++++--- src/views/Landing/components/InstallBridge/index.js | 2 +- src/views/Landing/index.js | 2 +- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/actions/RouterActions.js b/src/actions/RouterActions.js index c5cd20c1..e47a72d8 100644 --- a/src/actions/RouterActions.js +++ b/src/actions/RouterActions.js @@ -152,7 +152,8 @@ export const getValidUrl = (action: RouterAction): PayloadAction => (dis const shouldBeLandingPage = getState().devices.length < 1 || !getState().wallet.ready || getState().connect.error !== null; const landingPageUrl = dispatch(isLandingPageUrl(requestedUrl)); if (shouldBeLandingPage) { - return !landingPageUrl ? '/' : requestedUrl; + const landingPageRoute = dispatch(isLandingPageUrl(requestedUrl, true)); + return !landingPageRoute ? '/' : requestedUrl; } // Disallow displaying landing page @@ -283,11 +284,17 @@ const goto = (url: string): ThunkAction => (dispatch: Dispatch, getState: GetSta /* * Check if requested OR current url is landing page */ -export const isLandingPageUrl = ($url?: string): PayloadAction => (dispatch: Dispatch, getState: GetState): boolean => { +export const isLandingPageUrl = ($url?: string, checkRoutes: boolean = false): PayloadAction => (dispatch: Dispatch, getState: GetState): boolean => { let url: ?string = $url; if (typeof url !== 'string') { url = getState().router.location.pathname; } + if (checkRoutes) { + const isLandingRoute = routes.find(r => r.pattern === url && r.name.indexOf('landing') >= 0); + if (isLandingRoute) { + return true; + } + } return url === '/'; }; @@ -334,7 +341,7 @@ export const gotoFirmwareUpdate = (): ThunkAction => (dispatch: Dispatch, getSta */ export const setInitialUrl = (): PayloadAction => (dispatch: Dispatch, getState: GetState): boolean => { const { initialPathname } = getState().wallet; - if (typeof initialPathname === 'string' && !dispatch(isLandingPageUrl(initialPathname))) { + if (typeof initialPathname === 'string' && !dispatch(isLandingPageUrl(initialPathname, true))) { const valid = dispatch(getValidUrl({ type: LOCATION_CHANGE, payload: { diff --git a/src/views/Landing/components/InstallBridge/index.js b/src/views/Landing/components/InstallBridge/index.js index a53704ff..3f1a1703 100644 --- a/src/views/Landing/components/InstallBridge/index.js +++ b/src/views/Landing/components/InstallBridge/index.js @@ -131,7 +131,7 @@ class InstallBridge extends Component { const currentTarget: ?InstallTarget = installers.find(i => i.preferred === true); this.state = { - currentVersion: props.transport.type ? `Your version ${props.transport.version}` : 'Not installed', + currentVersion: props.transport.type && props.transport.type === 'bridge' ? `Your version ${props.transport.version}` : 'Not installed', latestVersion: props.transport.bridge.version.join('.'), installers, target: currentTarget || installers[0], diff --git a/src/views/Landing/index.js b/src/views/Landing/index.js index 7c6ea3e9..3dbf8174 100644 --- a/src/views/Landing/index.js +++ b/src/views/Landing/index.js @@ -106,7 +106,7 @@ export default (props: Props) => { {shouldShowUnsupportedBrowser && } {shouldShowInstallBridge && } - {(shouldShowConnectDevice || shouldShowDisconnectDevice) && ( + {!shouldShowInstallBridge && (shouldShowConnectDevice || shouldShowDisconnectDevice) && (

The private bank in your hands.