mirror of
https://github.com/trezor/trezor-wallet
synced 2025-02-15 09:32:00 +00:00
cleaner code for WALLET.SET_INITIAL_URL
This commit is contained in:
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…
Reference in New Issue
Block a user