@@ -5,21 +5,19 @@ 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 , UPDATE_SETTING } from '../actions' ;
9- import authentication from '../middleware/authentication' ;
8+ import { fetchNotifications , UPDATE_SETTING , LOGIN_SUCCESS , LOGOUT } from '../actions' ;
109import constants from '../utils/constants' ;
1110import notifications from '../middleware/notifications' ;
1211import requests from '../middleware/requests' ;
1312import rootReducer from '../reducers' ;
1413
1514export default function configureStore ( initialState ) {
16- const engine = filter ( createEngine ( constants . STORAGE_KEY ) , [ 'settings' ] ) ;
17- const storageMiddleware = storage . createMiddleware ( engine , [ ] , [ UPDATE_SETTING ] ) ;
15+ const engine = filter ( createEngine ( constants . STORAGE_KEY ) , [ 'settings' , [ 'auth' , 'token' ] ] ) ;
16+ const storageMiddleware = storage . createMiddleware ( engine , [ ] , [ UPDATE_SETTING , LOGIN_SUCCESS , LOGOUT ] ) ;
1817
1918 const createStoreWithMiddleware = applyMiddleware (
2019 requests , // Should be passed before 'apiMiddleware'
2120 apiMiddleware ,
22- authentication ,
2321 notifications ,
2422 storageMiddleware
2523 ) ( createStore ) ;
@@ -31,9 +29,7 @@ export default function configureStore(initialState) {
3129 load ( store )
3230 . then ( function ( newState ) {
3331 // Check if the user is logged in
34- store . dispatch ( checkAuth ( ) ) ;
3532 const isLoggedIn = store . getState ( ) . auth . token !== null ;
36-
3733 if ( isLoggedIn ) { store . dispatch ( fetchNotifications ( ) ) ; }
3834 } ) ;
3935
0 commit comments