diff options
| -rw-r--r-- | app/app.js | 11 | ||||
| -rw-r--r-- | app/store.js | 46 |
2 files changed, 26 insertions, 31 deletions
diff --git a/app/app.js b/app/app.js index ebc105dd17..960a9b6a78 100644 --- a/app/app.js +++ b/app/app.js @@ -1,7 +1,7 @@ import React from 'react'; import ReactDOM from 'react-dom'; import { Provider } from 'react-redux'; -import { Router, hashHistory } from 'react-router'; +import { Router, createMemoryHistory } from 'react-router'; import { syncHistoryWithStore, replace } from 'react-router-redux'; import { webFrame, ipcRenderer } from 'electron'; import routes from './routes'; @@ -12,15 +12,14 @@ import Backend from './lib/backend'; import { LoginState, ConnectionState } from './constants'; const initialState = {}; -const store = configureStore(initialState); +const memoryHistory = createMemoryHistory(); +const store = configureStore(initialState, memoryHistory); // desperately trying to fix https://github.com/reactjs/react-router-redux/issues/534 -hashHistory.replace('/'); +memoryHistory.replace('/'); -// see https://github.com/reactjs/react-router-redux/issues/534 const recentLocation = (store.getState().routing || {}).locationBeforeTransitions; -const routerHistory = syncHistoryWithStore(hashHistory, store, { adjustUrlOnReplay: true }); - +const routerHistory = syncHistoryWithStore(memoryHistory, store, { adjustUrlOnReplay: true }); if(recentLocation && recentLocation.pathname) { routerHistory.replace(recentLocation.pathname); } diff --git a/app/store.js b/app/store.js index 852712e345..c2ccbf3b4a 100644 --- a/app/store.js +++ b/app/store.js @@ -1,5 +1,4 @@ import { createStore, applyMiddleware, combineReducers, compose } from 'redux'; -import { hashHistory } from 'react-router'; import { routerMiddleware, routerReducer as routing, push, replace } from 'react-router-redux'; import persistState from 'redux-localstorage'; import thunk from 'redux-thunk'; @@ -11,34 +10,31 @@ import userActions from './actions/user'; import connectActions from './actions/connect'; import settingsActions from './actions/settings'; -const router = routerMiddleware(hashHistory); - -const actionCreators = { - ...userActions, - ...connectActions, - ...settingsActions, - pushRoute: (route) => push(route), - replaceRoute: (route) => replace(route), -}; +export default function configureStore(initialState, routerHistory) { + const router = routerMiddleware(routerHistory); + + const actionCreators = { + ...userActions, + ...connectActions, + ...settingsActions, + pushRoute: (route) => push(route), + replaceRoute: (route) => replace(route), + }; -const reducers = { - user, - connect, - settings, - routing -}; + const reducers = { + user, connect, settings, routing + }; -const middlewares = [ thunk, router ]; + const middlewares = [ thunk, router ]; -const composeEnhancers = (() => { - const compose_ = window && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__; - if(process.env.NODE_ENV === 'development' && compose_) { - return compose_({ actionCreators }); - } - return compose; -})(); + const composeEnhancers = (() => { + const reduxCompose = window && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__; + if(process.env.NODE_ENV === 'development' && reduxCompose) { + return reduxCompose({ actionCreators }); + } + return compose; + })(); -export default function configureStore(initialState) { const enhancer = composeEnhancers(applyMiddleware(...middlewares), persistState()); const rootReducer = combineReducers(reducers); |
