mirror of
https://github.com/trezor/trezor-wallet
synced 2024-11-28 11:18:16 +00:00
redirect to initial url after acquiring device
1. try to redirect after DEVICE.CONNECT event 2. clear initial url when redirection is done
This commit is contained in:
parent
835906bf96
commit
20c503c164
@ -2,6 +2,7 @@
|
||||
|
||||
import { push, LOCATION_CHANGE } from 'react-router-redux';
|
||||
import { CONTEXT_NONE } from 'actions/constants/modal';
|
||||
import { SET_INITIAL_URL } from 'actions/constants/wallet';
|
||||
import { routes } from 'support/routes';
|
||||
import * as deviceUtils from 'utils/device';
|
||||
|
||||
@ -57,7 +58,7 @@ export const paramsValidation = (params: RouterLocationState): PayloadAction<boo
|
||||
if (params.hasOwnProperty('deviceInstance')) {
|
||||
device = devices.find(d => d.features && d.features.device_id === params.device && d.instance === parseInt(params.deviceInstance, 10));
|
||||
} else {
|
||||
device = devices.find(d => d.path === params.device || (d.features && d.features.device_id === params.device));
|
||||
device = devices.find(d => ((!d.features || d.mode === 'bootloader') && d.path === params.device) || (d.features && d.features.device_id === params.device));
|
||||
}
|
||||
|
||||
if (!device) return false;
|
||||
@ -247,6 +248,8 @@ const sortDevices = (devices: Array<TrezorDevice>): Array<TrezorDevice> => devic
|
||||
* Redirect to requested device
|
||||
*/
|
||||
export const selectDevice = (device: TrezorDevice | Device): ThunkAction => (dispatch: Dispatch, getState: GetState): void => {
|
||||
if (dispatch(setInitialUrl())) return;
|
||||
|
||||
const url: ?string = dispatch(getDeviceUrl(device));
|
||||
if (!url) return;
|
||||
|
||||
@ -352,7 +355,12 @@ export const setInitialUrl = (): PayloadAction<boolean> => (dispatch: Dispatch,
|
||||
state: {},
|
||||
},
|
||||
}));
|
||||
|
||||
if (valid === initialPathname) {
|
||||
// reset initial url
|
||||
dispatch({
|
||||
type: SET_INITIAL_URL,
|
||||
});
|
||||
dispatch(goto(valid));
|
||||
return true;
|
||||
}
|
||||
|
@ -47,7 +47,9 @@ const WalletService: Middleware = (api: MiddlewareAPI) => (next: MiddlewareDispa
|
||||
|
||||
switch (action.type) {
|
||||
case WALLET.SET_INITIAL_URL:
|
||||
api.dispatch(LocalStorageActions.loadData());
|
||||
if (action.pathname) {
|
||||
api.dispatch(LocalStorageActions.loadData());
|
||||
}
|
||||
break;
|
||||
case WALLET.SET_SELECTED_DEVICE:
|
||||
// try to authorize device
|
||||
|
Loading…
Reference in New Issue
Block a user