import { combineReducers } from 'redux';
import merge from 'lodash.merge';

// Updates an entity cache in response to any action with response.entities.
function entities(state = {}, action) {
  if (action.response && action.response.entities) {
    return merge({}, state, action.response.entities);
  }
  return state;
}


function pagination(state = {}, action) {
  switch (action.type) {
    case 'HOME_SUCCESS':
      return merge({}, state, Object.keys(action.response.result).reduce((acc, key) => {
        acc[key] = { ids: action.response.result[key] };
        return acc;
      }, {}));

    default:
      return state;
  }
}

export default combineReducers({
  entities,
  pagination
});

@@ -496,18 +496,16 @@
  key) =%3E
- %7B
 %0A       
@@ -509,18 +509,25 @@
     
+(%7B ...
 acc
+, 
 %5Bkey%5D
- =
+:
  %7B i
@@ -563,41 +563,22 @@
 y%5D %7D
-;%0A        return acc;
+ %7D), %7B%7D
 %0A      
-%7D, %7B%7D
 ));%0A

Add home actions