--- a/client/src/store/configureStore.js Fri Jun 23 18:50:57 2017 +0200
+++ b/client/src/store/configureStore.js Mon Jun 26 15:21:06 2017 +0200
@@ -1,5 +1,6 @@
import rootReducer from '../reducers';
-import rootSaga from '../sagas';
+import rootAuthSaga from '../sagas/authSaga';
+import networkSaga from '../sagas/networkSaga';
import { compose, createStore, applyMiddleware } from 'redux';
import { routerMiddleware } from 'react-router-redux';
import createSagaMiddleware from 'redux-saga'
@@ -14,6 +15,7 @@
import APIClient from '../api/APIClient';
import createEffect from '../api';
import config from '../config';
+import { offlineConfigInitialized } from '../actions/networkActions';
// const composeEnhancers = (process.env.NODE_ENV !== 'production' && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__) ?
// window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({
@@ -53,7 +55,6 @@
...offlineDefaultConfig,
persistOptions,
effect: createEffect(apiClient),
-// detectNetwork: callback => callback(true),
}
const storeInitialState = { ...defaultState };
@@ -64,6 +65,8 @@
const router = routerMiddleware(history);
const saga = createSagaMiddleware();
+ offlineConfig.detectNetwork = callback => { saga.run(networkSaga, { callback }); };
+
const store = offline(offlineConfig)(createStore)(rootReducer, initialState, composeEnhancers(
applyMiddleware(router, saga)
));
@@ -75,7 +78,9 @@
history
}
- saga.run(rootSaga, context);
+ saga.run(rootAuthSaga, context);
+
+ store.dispatch(offlineConfigInitialized({ client: apiClient }))
return store;
};