1
0
mirror of https://github.com/trezor/trezor-wallet synced 2024-11-13 20:08:56 +00:00
trezor-wallet/src/js/store/index.js

77 lines
2.2 KiB
JavaScript
Raw Normal View History

2017-12-13 11:01:37 +00:00
/* @flow */
'use strict';
2018-04-16 21:19:50 +00:00
import { createStore, applyMiddleware, compose } from 'redux';
import { routerMiddleware, push } from 'react-router-redux';
import thunk from 'redux-thunk';
// import createHistory from 'history/createBrowserHistory';
// import { useRouterHistory } from 'react-router';
import createHistory from 'history/createHashHistory';
import { createLogger } from 'redux-logger';
import reducers from '../reducers';
import services from '../services';
2018-05-11 19:01:43 +00:00
import Raven from 'raven-js';
2018-04-16 21:19:50 +00:00
import RavenMiddleware from 'redux-raven-middleware';
import type { Action, GetState, Store } from '~/flowtype';
2018-04-16 21:19:50 +00:00
2018-05-05 11:52:03 +00:00
export const history: History = createHistory( { queryKey: false } );
2018-04-16 21:19:50 +00:00
2018-05-11 19:01:43 +00:00
const RAVEN_KEY: string = 'https://497392c3ff6e46dc9e54eef123979378@sentry.io/294339'
Raven.config(RAVEN_KEY).install();
2018-04-16 21:19:50 +00:00
const initialState: any = {};
const enhancers = [];
const middleware = [
thunk,
2018-05-11 19:01:43 +00:00
RavenMiddleware(RAVEN_KEY),
2018-04-16 21:19:50 +00:00
routerMiddleware(history)
];
2018-05-05 11:52:03 +00:00
let composedEnhancers: any;
2018-04-16 21:19:50 +00:00
if (process.env.NODE_ENV === 'development') {
2018-05-05 11:52:03 +00:00
const excludeLogger = (getState: GetState, action: Action): boolean => {
//'@@router/LOCATION_CHANGE'
const excluded: Array<string> = ['LOG_TO_EXCLUDE', 'log__add'];
const pass: Array<string> = excluded.filter((act) => {
return action.type === act;
});
return pass.length === 0;
}
const logger = createLogger({
level: 'info',
predicate: excludeLogger,
collapsed: true
});
2018-04-16 21:19:50 +00:00
const devToolsExtension: ?Function = window.devToolsExtension;
if (typeof devToolsExtension === 'function') {
enhancers.push(devToolsExtension());
}
2018-05-05 11:52:03 +00:00
composedEnhancers = compose(
applyMiddleware(...middleware, logger, ...services),
...enhancers
);
} else {
composedEnhancers = compose(
applyMiddleware(...middleware, ...services),
...enhancers
);
}
2018-04-16 21:19:50 +00:00
export default createStore(
reducers,
initialState,
composedEnhancers
);
// if (process.env.NODE_ENV === 'production') {
// module.exports = require('./store.dev'); // eslint-disable-line global-require
// } else {
// module.exports = require('./store.dev'); // eslint-disable-line global-require
// }