import { asImmutable } from '../../../helper/immutableHelper';
import * as actions from './actions';

const initialState = asImmutable({});

export const reducer = (state = initialState, { type, payload }) => {
  switch (type) {
    case actions.FETCH_USER.SUCCEEDED:
      return state.merge(payload.data || {});
    case actions.FETCH_USER_NOTES.SUCCEEDED:
      return state.merge({
        notes: payload.data || []
      });
    case actions.STORE_USER_NOTE.SUCCEEDED:
      return state.mergeIn(['notes'], [payload.data]);
    case actions.FETCH_REPOSITORIES.SUCCEEDED:
      return state.merge({
        repositories: payload.data || []
      });
    default:
      return state;
  }
};

export default reducer;

@@ -490,28 +490,57 @@
 ate.
-mergeIn(%5B
+set(
 'notes'
-%5D
 , 
-%5B
+state.get('notes').push(asImmutable(
 payl
@@ -547,17 +547,18 @@
 oad.data
-%5D
+))
 );%0A    c

Fix problem of note replacement