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 { push, LOCATION_CHANGE } from 'react-router-redux';
|
||||||
import { CONTEXT_NONE } from 'actions/constants/modal';
|
import { CONTEXT_NONE } from 'actions/constants/modal';
|
||||||
|
import { SET_INITIAL_URL } from 'actions/constants/wallet';
|
||||||
import { routes } from 'support/routes';
|
import { routes } from 'support/routes';
|
||||||
import * as deviceUtils from 'utils/device';
|
import * as deviceUtils from 'utils/device';
|
||||||
|
|
||||||
@ -57,7 +58,7 @@ export const paramsValidation = (params: RouterLocationState): PayloadAction<boo
|
|||||||
if (params.hasOwnProperty('deviceInstance')) {
|
if (params.hasOwnProperty('deviceInstance')) {
|
||||||
device = devices.find(d => d.features && d.features.device_id === params.device && d.instance === parseInt(params.deviceInstance, 10));
|
device = devices.find(d => d.features && d.features.device_id === params.device && d.instance === parseInt(params.deviceInstance, 10));
|
||||||
} else {
|
} 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;
|
if (!device) return false;
|
||||||
@ -247,6 +248,8 @@ const sortDevices = (devices: Array<TrezorDevice>): Array<TrezorDevice> => devic
|
|||||||
* Redirect to requested device
|
* Redirect to requested device
|
||||||
*/
|
*/
|
||||||
export const selectDevice = (device: TrezorDevice | Device): ThunkAction => (dispatch: Dispatch, getState: GetState): void => {
|
export const selectDevice = (device: TrezorDevice | Device): ThunkAction => (dispatch: Dispatch, getState: GetState): void => {
|
||||||
|
if (dispatch(setInitialUrl())) return;
|
||||||
|
|
||||||
const url: ?string = dispatch(getDeviceUrl(device));
|
const url: ?string = dispatch(getDeviceUrl(device));
|
||||||
if (!url) return;
|
if (!url) return;
|
||||||
|
|
||||||
@ -352,7 +355,12 @@ export const setInitialUrl = (): PayloadAction<boolean> => (dispatch: Dispatch,
|
|||||||
state: {},
|
state: {},
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
if (valid === initialPathname) {
|
if (valid === initialPathname) {
|
||||||
|
// reset initial url
|
||||||
|
dispatch({
|
||||||
|
type: SET_INITIAL_URL,
|
||||||
|
});
|
||||||
dispatch(goto(valid));
|
dispatch(goto(valid));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,9 @@ const WalletService: Middleware = (api: MiddlewareAPI) => (next: MiddlewareDispa
|
|||||||
|
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case WALLET.SET_INITIAL_URL:
|
case WALLET.SET_INITIAL_URL:
|
||||||
api.dispatch(LocalStorageActions.loadData());
|
if (action.pathname) {
|
||||||
|
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