mirror of
https://github.com/trezor/trezor-wallet
synced 2025-03-28 14:05:44 +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,
|
type: typeof WALLET.SET_INITIAL_URL,
|
||||||
state?: RouterLocationState,
|
state?: RouterLocationState,
|
||||||
pathname?: ?string,
|
pathname?: string,
|
||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
type: typeof WALLET.TOGGLE_DEVICE_DROPDOWN,
|
type: typeof WALLET.TOGGLE_DEVICE_DROPDOWN,
|
||||||
|
@ -32,12 +32,13 @@ const WalletService: Middleware = (api: MiddlewareAPI) => (next: MiddlewareDispa
|
|||||||
// exclude landing page url
|
// exclude landing page url
|
||||||
const { pathname } = action.payload.location;
|
const { pathname } = action.payload.location;
|
||||||
const isValidPath = !api.dispatch(RouterActions.isLandingPageUrl(pathname, true));
|
const isValidPath = !api.dispatch(RouterActions.isLandingPageUrl(pathname, true));
|
||||||
api.dispatch({
|
if (isValidPath) {
|
||||||
type: WALLET.SET_INITIAL_URL,
|
api.dispatch({
|
||||||
pathname: isValidPath ? pathname : null,
|
type: WALLET.SET_INITIAL_URL,
|
||||||
state: {},
|
pathname,
|
||||||
});
|
state: {},
|
||||||
|
});
|
||||||
|
}
|
||||||
// pass action and break process
|
// pass action and break process
|
||||||
return next(action);
|
return next(action);
|
||||||
}
|
}
|
||||||
@ -46,10 +47,8 @@ const WalletService: Middleware = (api: MiddlewareAPI) => (next: MiddlewareDispa
|
|||||||
next(action);
|
next(action);
|
||||||
|
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case WALLET.SET_INITIAL_URL:
|
case WALLET.SET_FIRST_LOCATION_CHANGE:
|
||||||
if (action.hasOwnProperty('pathname')) {
|
api.dispatch(LocalStorageActions.loadData());
|
||||||
api.dispatch(LocalStorageActions.loadData());
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case WALLET.SET_SELECTED_DEVICE:
|
case WALLET.SET_SELECTED_DEVICE:
|
||||||
// try to authorize device
|
// try to authorize device
|
||||||
|
Loading…
Reference in New Issue
Block a user