diff --git a/src/actions/RouterActions.js b/src/actions/RouterActions.js index cefebc27..440f991a 100644 --- a/src/actions/RouterActions.js +++ b/src/actions/RouterActions.js @@ -2,7 +2,7 @@ import { push, LOCATION_CHANGE } from 'connected-react-router'; import { CONTEXT_NONE } from 'actions/constants/modal'; -import { SET_INITIAL_URL } from 'actions/constants/wallet'; +import { SET_INITIAL_URL, SET_FIRST_LOCATION_CHANGE } from 'actions/constants/wallet'; import { routes } from 'support/routes'; import * as deviceUtils from 'utils/device'; @@ -133,7 +133,12 @@ export const getValidUrl = (action: RouterAction): PayloadAction => (dis const { firstLocationChange } = getState().wallet; // redirect to landing page (loading screen) // and wait until application is ready - if (firstLocationChange) return '/'; + if (firstLocationChange) { + dispatch({ + type: SET_FIRST_LOCATION_CHANGE, + }); + return '/'; + } console.log('action', action); diff --git a/src/actions/WalletActions.js b/src/actions/WalletActions.js index 9fe17a93..9e5ea9f9 100644 --- a/src/actions/WalletActions.js +++ b/src/actions/WalletActions.js @@ -39,7 +39,7 @@ export type WalletAction = { type: typeof WALLET.CLEAR_UNAVAILABLE_DEVICE_DATA, devices: Array } | { - type: typeof WALLET.SHOW_BETA_DISCLAIMER | typeof WALLET.HIDE_BETA_DISCLAIMER, + type: typeof WALLET.SHOW_BETA_DISCLAIMER | typeof WALLET.HIDE_BETA_DISCLAIMER | typeof WALLET.SET_FIRST_LOCATION_CHANGE, } export const init = (): ThunkAction => (dispatch: Dispatch): void => { diff --git a/src/actions/constants/wallet.js b/src/actions/constants/wallet.js index 6f449a7a..04615371 100644 --- a/src/actions/constants/wallet.js +++ b/src/actions/constants/wallet.js @@ -2,6 +2,7 @@ export const TOGGLE_DEVICE_DROPDOWN: 'wallet__toggle_dropdown' = 'wallet__toggle_dropdown'; export const SET_INITIAL_URL: 'wallet__set_initial_url' = 'wallet__set_initial_url'; +export const SET_FIRST_LOCATION_CHANGE: 'wallet__set_first_location_change' = 'wallet__set_first_location_change'; export const ONLINE_STATUS: 'wallet__online_status' = 'wallet__online_status'; export const SET_SELECTED_DEVICE: 'wallet__set_selected_device' = 'wallet__set_selected_device'; diff --git a/src/flowtype/npm/react-router-redux.js b/src/flowtype/npm/react-router-redux.js index 6401dc77..98040f88 100644 --- a/src/flowtype/npm/react-router-redux.js +++ b/src/flowtype/npm/react-router-redux.js @@ -19,7 +19,10 @@ declare module 'connected-react-router' { declare export type RouterAction = { type: typeof LOCATION_CHANGE, - payload: Location; + payload: { + action: string, + location: Location, + }, } declare export type State = { @@ -35,6 +38,7 @@ declare module 'connected-react-router' { //declare export function routerReducer(state?: S, action: A): S; declare export function routerReducer(state?: State, action: any): State; declare export function routerMiddleware(history: any): any; + declare export function connectRouter(history: any): any; declare export class ConnectedRouter extends React$Component<{ history: any diff --git a/src/reducers/WalletReducer.js b/src/reducers/WalletReducer.js index 9a76caad..8f07dc6e 100644 --- a/src/reducers/WalletReducer.js +++ b/src/reducers/WalletReducer.js @@ -36,11 +36,14 @@ const initialState: State = { export default function wallet(state: State = initialState, action: Action): State { switch (action.type) { case WALLET.SET_INITIAL_URL: - console.log('action2', action); return { ...state, initialParams: action.state, initialPathname: action.pathname, + }; + case WALLET.SET_FIRST_LOCATION_CHANGE: + return { + ...state, firstLocationChange: false, }; diff --git a/src/services/RouterService.js b/src/services/RouterService.js index 6611ccfe..d1ff6407 100644 --- a/src/services/RouterService.js +++ b/src/services/RouterService.js @@ -28,6 +28,7 @@ const RouterService: Middleware = (api: MiddlewareAPI) => (next: MiddlewareDispa console.log('api.dispatch(RouterActions.pathToParams(validUrl))', api.dispatch(RouterActions.pathToParams(validUrl))); override.payload.location.state = api.dispatch(RouterActions.pathToParams(validUrl)); const redirect = action.payload.location.pathname !== validUrl; + console.warn('OVERRIDE', action.payload.location.pathname, validUrl); if (redirect) { // override action pathname override.payload.location.pathname = validUrl;