cleaner code for WALLET.SET_INITIAL_URL

pull/500/head
Szymon Lesisz 5 years ago
parent 5b98deac1e
commit 6cfff6d598

@ -23,7 +23,7 @@ export type WalletAction =
| {
type: typeof WALLET.SET_INITIAL_URL,
state?: RouterLocationState,
pathname?: ?string,
pathname?: string,
}
| {
type: typeof WALLET.TOGGLE_DEVICE_DROPDOWN,

@ -32,12 +32,13 @@ const WalletService: Middleware = (api: MiddlewareAPI) => (next: MiddlewareDispa
// exclude landing page url
const { pathname } = action.payload.location;
const isValidPath = !api.dispatch(RouterActions.isLandingPageUrl(pathname, true));
api.dispatch({
type: WALLET.SET_INITIAL_URL,
pathname: isValidPath ? pathname : null,
state: {},
});
if (isValidPath) {
api.dispatch({
type: WALLET.SET_INITIAL_URL,
pathname,
state: {},
});
}
// pass action and break process
return next(action);
}
@ -46,10 +47,8 @@ const WalletService: Middleware = (api: MiddlewareAPI) => (next: MiddlewareDispa
next(action);
switch (action.type) {
case WALLET.SET_INITIAL_URL:
if (action.hasOwnProperty('pathname')) {
api.dispatch(LocalStorageActions.loadData());
}
case WALLET.SET_FIRST_LOCATION_CHANGE:
api.dispatch(LocalStorageActions.loadData());
break;
case WALLET.SET_SELECTED_DEVICE:
// try to authorize device

Loading…
Cancel
Save