1
0
mirror of https://github.com/trezor/trezor-wallet synced 2024-11-28 03:08:30 +00:00

fix Router service to allow LOCATION_CHANGE while popup is connected

but context device is disconnected
This commit is contained in:
Szymon Lesisz 2018-05-22 20:05:58 +02:00
parent ad3237a49a
commit 241fc5acdc

View File

@ -112,7 +112,10 @@ const RouterService: Middleware = (api: MiddlewareAPI) => (next: MiddlewareDispa
// if web3 wasn't initialized yet or there are no devices attached or initialization error occurs // if web3 wasn't initialized yet or there are no devices attached or initialization error occurs
const landingPage: boolean = web3.length < 1 || devices.length < 1 || error !== null; const landingPage: boolean = web3.length < 1 || devices.length < 1 || error !== null;
if (isModalOpened && action.payload.pathname !== location.pathname) { // modal is still opened and currentPath is still valid
// example 1 (valid blocking): url changes while passphrase modal opened but device is still connected (we want user to finish this action)
// example 2 (invalid blocking): url changes while passphrase modal opened because device disconnect
if (isModalOpened && action.payload.pathname !== location.pathname && validation(api, currentParams)) {
redirectPath = location.pathname; redirectPath = location.pathname;
console.warn("Modal still opened"); console.warn("Modal still opened");
} else if (landingPage) { } else if (landingPage) {
@ -152,7 +155,7 @@ const RouterService: Middleware = (api: MiddlewareAPI) => (next: MiddlewareDispa
} }
if (redirectPath) { if (redirectPath) {
console.warn("Redirecting...") console.warn("Redirecting...", redirectPath)
// override action to keep routerReducer sync // override action to keep routerReducer sync
const url: string = redirectPath; const url: string = redirectPath;
action.payload.state = pathToParams(url); action.payload.state = pathToParams(url);