@@ -5,7 +5,7 @@ import * as storage from 'redux-storage';
55import createEngine from 'redux-storage-engine-localstorage' ;
66import filter from 'redux-storage-decorator-filter' ;
77
8- import { checkAuth , fetchNotifications } from '../actions' ;
8+ import { checkAuth , fetchNotifications , UPDATE_SETTING } from '../actions' ;
99import authentication from '../middleware/authentication' ;
1010import constants from '../utils/constants' ;
1111import notifications from '../middleware/notifications' ;
@@ -14,7 +14,7 @@ import rootReducer from '../reducers';
1414
1515export 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