Skip to content
Snippets Groups Projects
Commit 3d14ee34 authored by James Calfee's avatar James Calfee
Browse files

Saving state.global.pathname (info from react router) #184

parent c489fb9d
No related branches found
No related tags found
No related merge requests found
import Immutable, {Map, fromJS} from 'immutable'; import {Map, fromJS} from 'immutable';
import {combineReducers} from 'redux'; import {combineReducers} from 'redux';
import {routerReducer} from 'react-router-redux'; import {routerReducer} from 'react-router-redux';
import appReducer from './AppReducer'; import appReducer from './AppReducer';
...@@ -14,9 +14,13 @@ import {contentStats} from 'app/utils/StateFunctions' ...@@ -14,9 +14,13 @@ import {contentStats} from 'app/utils/StateFunctions'
function initReducer(reducer, type) { function initReducer(reducer, type) {
return (state, action) => { return (state, action) => {
if(!state) return reducer(state, action);
// @@redux/INIT server and client init // @@redux/INIT server and client init
if (state && (action.type === '@@redux/INIT' || action.type === '@@INIT')) { if (action.type === '@@redux/INIT' || action.type === '@@INIT') {
state = state instanceof Map ? state : Immutable.fromJS(state); if(!(state instanceof Map)) {
state = fromJS(state);
}
if(type === 'global') { if(type === 'global') {
const content = state.get('content').withMutations(c => { const content = state.get('content').withMutations(c => {
c.forEach((cc, key) => { c.forEach((cc, key) => {
...@@ -28,6 +32,12 @@ function initReducer(reducer, type) { ...@@ -28,6 +32,12 @@ function initReducer(reducer, type) {
} }
return state return state
} }
if (action.type === '@@router/LOCATION_CHANGE' && type === 'global') {
state = state.set('pathname', action.payload.pathname)
// console.log(action.type, type, action, state.toJS())
}
return reducer(state, action); return reducer(state, action);
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment