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/react-redux/.*
|
||||||
.*/node_modules/redux/.*
|
.*/node_modules/redux/.*
|
||||||
.*/node_modules/react-router/.*
|
.*/node_modules/react-router/.*
|
||||||
.*/node_modules/react-router-redux/.*
|
|
||||||
.*/node_modules/oboe/test/.*
|
.*/node_modules/oboe/test/.*
|
||||||
.*/_old/.*
|
.*/_old/.*
|
||||||
.*/scripts/solidity/.*
|
.*/scripts/solidity/.*
|
||||||
@ -17,7 +16,7 @@
|
|||||||
./src/flowtype/npm/react-redux_v5.x.x.js
|
./src/flowtype/npm/react-redux_v5.x.x.js
|
||||||
./src/flowtype/npm/react-router_v4.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-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/bignumber.js
|
||||||
./src/flowtype/npm/ethereum-types.js
|
./src/flowtype/npm/ethereum-types.js
|
||||||
./src/flowtype/npm/web3.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 => {
|
export const paramsValidation = (params: RouterLocationState): PayloadAction<boolean> => (dispatch: Dispatch, getState: GetState): boolean => {
|
||||||
// validate requested device
|
// validate requested device
|
||||||
|
|
||||||
console.log('params', params);
|
|
||||||
if (params.hasOwnProperty('device')) {
|
if (params.hasOwnProperty('device')) {
|
||||||
const { devices } = getState();
|
const { devices } = getState();
|
||||||
|
|
||||||
@ -140,8 +139,6 @@ export const getValidUrl = (action: RouterAction): PayloadAction<string> => (dis
|
|||||||
return '/';
|
return '/';
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('action', action);
|
|
||||||
|
|
||||||
const requestedUrl = action.payload.location.pathname;
|
const requestedUrl = action.payload.location.pathname;
|
||||||
// Corner case: LOCATION_CHANGE was called but pathname didn't changed (redirect action from RouterService)
|
// Corner case: LOCATION_CHANGE was called but pathname didn't changed (redirect action from RouterService)
|
||||||
if (requestedUrl === location.pathname) return requestedUrl;
|
if (requestedUrl === location.pathname) return requestedUrl;
|
||||||
@ -277,7 +274,6 @@ export const selectFirstAvailableDevice = (gotoRoot: boolean = false): ThunkActi
|
|||||||
const url = dispatch(getFirstAvailableDeviceUrl());
|
const url = dispatch(getFirstAvailableDeviceUrl());
|
||||||
if (url) {
|
if (url) {
|
||||||
const currentParams = getState().router.location.state;
|
const currentParams = getState().router.location.state;
|
||||||
console.log('currentParams', currentParams);
|
|
||||||
const requestedParams = dispatch(pathToParams(url));
|
const requestedParams = dispatch(pathToParams(url));
|
||||||
if (gotoRoot || currentParams.device !== requestedParams.device || currentParams.deviceInstance !== requestedParams.deviceInstance) {
|
if (gotoRoot || currentParams.device !== requestedParams.device || currentParams.deviceInstance !== requestedParams.deviceInstance) {
|
||||||
dispatch(goto(url));
|
dispatch(goto(url));
|
||||||
|
@ -42,5 +42,5 @@ declare module 'connected-react-router' {
|
|||||||
|
|
||||||
declare export class ConnectedRouter extends React$Component<{
|
declare export class ConnectedRouter extends React$Component<{
|
||||||
history: any
|
history: any
|
||||||
}> {}
|
}> {}
|
||||||
}
|
}
|
@ -1,6 +1,7 @@
|
|||||||
/* @flow */
|
/* @flow */
|
||||||
import { combineReducers } from 'redux';
|
import { combineReducers } from 'redux';
|
||||||
import { connectRouter } from 'connected-react-router';
|
import { connectRouter } from 'connected-react-router';
|
||||||
|
import type { State } from 'connected-react-router';
|
||||||
|
|
||||||
import log from 'reducers/LogReducer';
|
import log from 'reducers/LogReducer';
|
||||||
import localStorage from 'reducers/LocalStorageReducer';
|
import localStorage from 'reducers/LocalStorageReducer';
|
||||||
@ -23,8 +24,7 @@ import devices from 'reducers/DevicesReducer';
|
|||||||
import blockchain from 'reducers/BlockchainReducer';
|
import blockchain from 'reducers/BlockchainReducer';
|
||||||
import signVerify from 'reducers/SignVerifyReducer';
|
import signVerify from 'reducers/SignVerifyReducer';
|
||||||
|
|
||||||
export default history => combineReducers({
|
const reducers = {
|
||||||
router: connectRouter(history),
|
|
||||||
log,
|
log,
|
||||||
localStorage,
|
localStorage,
|
||||||
connect,
|
connect,
|
||||||
@ -45,8 +45,16 @@ export default history => combineReducers({
|
|||||||
devices,
|
devices,
|
||||||
blockchain,
|
blockchain,
|
||||||
signVerify,
|
signVerify,
|
||||||
});
|
router: () => ({
|
||||||
|
location: {}, hash: {}, state: {}, network: {},
|
||||||
|
}: State),
|
||||||
|
};
|
||||||
|
|
||||||
export type Reducers = typeof reducers;
|
export type Reducers = typeof reducers;
|
||||||
type $ExtractFunctionReturn = <V>(v: (...args: any) => V) => V;
|
type $ExtractFunctionReturn = <V>(v: (...args: any) => V) => V;
|
||||||
export type ReducersState = $ObjMap<Reducers, $ExtractFunctionReturn>;
|
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));
|
const validUrl = api.dispatch(RouterActions.getValidUrl(action));
|
||||||
// override action state (to be stored in RouterReducer)
|
// override action state (to be stored in RouterReducer)
|
||||||
const override = action;
|
const override = action;
|
||||||
console.log('api.dispatch(RouterActions.pathToParams(validUrl))', api.dispatch(RouterActions.pathToParams(validUrl)));
|
|
||||||
override.payload.location.state = api.dispatch(RouterActions.pathToParams(validUrl));
|
override.payload.location.state = api.dispatch(RouterActions.pathToParams(validUrl));
|
||||||
const redirect = action.payload.location.pathname !== validUrl;
|
const redirect = action.payload.location.pathname !== validUrl;
|
||||||
console.warn('OVERRIDE', action.payload.location.pathname, validUrl);
|
|
||||||
if (redirect) {
|
if (redirect) {
|
||||||
// override action pathname
|
// override action pathname
|
||||||
override.payload.location.pathname = validUrl;
|
override.payload.location.pathname = validUrl;
|
||||||
|
@ -96,7 +96,6 @@ const Wallet = (props: WalletContainerProps) => (
|
|||||||
<ContextNotifications />
|
<ContextNotifications />
|
||||||
<Log />
|
<Log />
|
||||||
<Body>
|
<Body>
|
||||||
{JSON.stringify(props.wallet)}
|
|
||||||
{ props.children }
|
{ props.children }
|
||||||
</Body>
|
</Body>
|
||||||
<Footer />
|
<Footer />
|
||||||
|
Loading…
Reference in New Issue
Block a user