From 3d14ee341be5911e7180253ac4b4202b542d6d01 Mon Sep 17 00:00:00 2001
From: James Calfee <james@jcalfee.info>
Date: Thu, 25 Aug 2016 11:44:04 -0500
Subject: [PATCH] Saving state.global.pathname (info from react router) #184

---
 app/redux/RootReducer.js | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/app/redux/RootReducer.js b/app/redux/RootReducer.js
index 0ac1a3822..4e35654f1 100644
--- a/app/redux/RootReducer.js
+++ b/app/redux/RootReducer.js
@@ -1,4 +1,4 @@
-import Immutable, {Map, fromJS} from 'immutable';
+import {Map, fromJS} from 'immutable';
 import {combineReducers} from 'redux';
 import {routerReducer} from 'react-router-redux';
 import appReducer from './AppReducer';
@@ -14,9 +14,13 @@ import {contentStats} from 'app/utils/StateFunctions'
 
 function initReducer(reducer, type) {
     return (state, action) => {
+        if(!state) return reducer(state, action);
+
         // @@redux/INIT server and client init
-        if (state && (action.type === '@@redux/INIT' || action.type === '@@INIT')) {
-            state = state instanceof Map ? state : Immutable.fromJS(state);
+        if (action.type === '@@redux/INIT' || action.type === '@@INIT') {
+            if(!(state instanceof Map)) {
+                state = fromJS(state);
+            }
             if(type === 'global') {
                 const content = state.get('content').withMutations(c => {
                     c.forEach((cc, key) => {
@@ -28,6 +32,12 @@ function initReducer(reducer, type) {
             }
             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);
     }
 }
-- 
GitLab