mirror of
https://github.com/trezor/trezor-wallet
synced 2025-01-13 17:40:55 +00:00
Fixed some flow
This commit is contained in:
parent
e7ae73c570
commit
e0501b1072
@ -6,7 +6,6 @@
|
||||
.*/node_modules/react-redux/.*
|
||||
.*/node_modules/redux/.*
|
||||
.*/node_modules/react-router/.*
|
||||
.*/node_modules/react-router-redux/.*
|
||||
.*/node_modules/oboe/test/.*
|
||||
.*/_old/.*
|
||||
.*/scripts/solidity/.*
|
||||
@ -17,7 +16,7 @@
|
||||
./src/flowtype/npm/react-redux_v5.x.x.js
|
||||
./src/flowtype/npm/react-router_v4.x.x.js
|
||||
./src/flowtype/npm/react-router-dom_v4.x.x.js
|
||||
./src/flowtype/npm/react-router-redux.js
|
||||
./src/flowtype/npm/connected-react-router.js
|
||||
./src/flowtype/npm/bignumber.js
|
||||
./src/flowtype/npm/ethereum-types.js
|
||||
./src/flowtype/npm/web3.js
|
||||
|
@ -52,7 +52,6 @@ export const pathToParams = (path: string): PayloadAction<RouterLocationState> =
|
||||
export const paramsValidation = (params: RouterLocationState): PayloadAction<boolean> => (dispatch: Dispatch, getState: GetState): boolean => {
|
||||
// validate requested device
|
||||
|
||||
console.log('params', params);
|
||||
if (params.hasOwnProperty('device')) {
|
||||
const { devices } = getState();
|
||||
|
||||
@ -140,8 +139,6 @@ export const getValidUrl = (action: RouterAction): PayloadAction<string> => (dis
|
||||
return '/';
|
||||
}
|
||||
|
||||
console.log('action', action);
|
||||
|
||||
const requestedUrl = action.payload.location.pathname;
|
||||
// Corner case: LOCATION_CHANGE was called but pathname didn't changed (redirect action from RouterService)
|
||||
if (requestedUrl === location.pathname) return requestedUrl;
|
||||
@ -277,7 +274,6 @@ export const selectFirstAvailableDevice = (gotoRoot: boolean = false): ThunkActi
|
||||
const url = dispatch(getFirstAvailableDeviceUrl());
|
||||
if (url) {
|
||||
const currentParams = getState().router.location.state;
|
||||
console.log('currentParams', currentParams);
|
||||
const requestedParams = dispatch(pathToParams(url));
|
||||
if (gotoRoot || currentParams.device !== requestedParams.device || currentParams.deviceInstance !== requestedParams.deviceInstance) {
|
||||
dispatch(goto(url));
|
||||
|
@ -1,6 +1,7 @@
|
||||
/* @flow */
|
||||
import { combineReducers } from 'redux';
|
||||
import { connectRouter } from 'connected-react-router';
|
||||
import type { State } from 'connected-react-router';
|
||||
|
||||
import log from 'reducers/LogReducer';
|
||||
import localStorage from 'reducers/LocalStorageReducer';
|
||||
@ -23,8 +24,7 @@ import devices from 'reducers/DevicesReducer';
|
||||
import blockchain from 'reducers/BlockchainReducer';
|
||||
import signVerify from 'reducers/SignVerifyReducer';
|
||||
|
||||
export default history => combineReducers({
|
||||
router: connectRouter(history),
|
||||
const reducers = {
|
||||
log,
|
||||
localStorage,
|
||||
connect,
|
||||
@ -45,8 +45,16 @@ export default history => combineReducers({
|
||||
devices,
|
||||
blockchain,
|
||||
signVerify,
|
||||
});
|
||||
router: () => ({
|
||||
location: {}, hash: {}, state: {}, network: {},
|
||||
}: State),
|
||||
};
|
||||
|
||||
export type Reducers = typeof reducers;
|
||||
type $ExtractFunctionReturn = <V>(v: (...args: any) => V) => V;
|
||||
export type ReducersState = $ObjMap<Reducers, $ExtractFunctionReturn>;
|
||||
|
||||
export default (history: any) => combineReducers({
|
||||
...reducers,
|
||||
router: connectRouter(history),
|
||||
});
|
@ -25,10 +25,8 @@ const RouterService: Middleware = (api: MiddlewareAPI) => (next: MiddlewareDispa
|
||||
const validUrl = api.dispatch(RouterActions.getValidUrl(action));
|
||||
// override action state (to be stored in RouterReducer)
|
||||
const override = action;
|
||||
console.log('api.dispatch(RouterActions.pathToParams(validUrl))', api.dispatch(RouterActions.pathToParams(validUrl)));
|
||||
override.payload.location.state = api.dispatch(RouterActions.pathToParams(validUrl));
|
||||
const redirect = action.payload.location.pathname !== validUrl;
|
||||
console.warn('OVERRIDE', action.payload.location.pathname, validUrl);
|
||||
if (redirect) {
|
||||
// override action pathname
|
||||
override.payload.location.pathname = validUrl;
|
||||
|
@ -96,7 +96,6 @@ const Wallet = (props: WalletContainerProps) => (
|
||||
<ContextNotifications />
|
||||
<Log />
|
||||
<Body>
|
||||
{JSON.stringify(props.wallet)}
|
||||
{ props.children }
|
||||
</Body>
|
||||
<Footer />
|
||||
|
Loading…
Reference in New Issue
Block a user