Skip to content

Commit 810e316

Browse files
Merge pull request #182 from ekonstantinidis/fix-redux-storage
Fix settings issue
2 parents 09e52d4 + ee92f80 commit 810e316

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/js/store/configureStore.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import * as storage from 'redux-storage';
55
import createEngine from 'redux-storage-engine-localstorage';
66
import filter from 'redux-storage-decorator-filter';
77

8-
import { checkAuth, fetchNotifications } from '../actions';
8+
import { checkAuth, fetchNotifications, UPDATE_SETTING } from '../actions';
99
import authentication from '../middleware/authentication';
1010
import constants from '../utils/constants';
1111
import notifications from '../middleware/notifications';
@@ -14,7 +14,7 @@ import rootReducer from '../reducers';
1414

1515
export default function configureStore(initialState) {
1616
const engine = filter(createEngine(constants.STORAGE_KEY), ['settings']);
17-
const storageMiddleware = storage.createMiddleware(engine);
17+
const storageMiddleware = storage.createMiddleware(engine, [], [UPDATE_SETTING]);
1818

1919
const createStoreWithMiddleware = applyMiddleware(
2020
requests, // Should be passed before 'apiMiddleware'
@@ -26,14 +26,14 @@ export default function configureStore(initialState) {
2626

2727
const store = createStoreWithMiddleware(rootReducer, initialState);
2828

29-
// Check if the user is logged in
30-
store.dispatch(checkAuth());
31-
const isLoggedIn = store.getState().auth.token !== null;
32-
3329
// Load settings from localStorage
3430
const load = storage.createLoader(engine);
3531
load(store)
3632
.then(function (newState) {
33+
// Check if the user is logged in
34+
store.dispatch(checkAuth());
35+
const isLoggedIn = store.getState().auth.token !== null;
36+
3737
if (isLoggedIn) { store.dispatch(fetchNotifications()); }
3838
});
3939

0 commit comments

Comments
 (0)