{"size": 526, "ext": "js", "max_stars_repo_path": "client/src/reducers/messages.js", "max_stars_repo_name": "oba14/start-chat", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "client/src/reducers/messages.js", "max_issues_repo_name": "oba14/start-chat", "max_issues_repo_issues_event_min_datetime": "2021-05-11T01:45:50.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-22T10:26:51.000Z", "max_forks_repo_path": "client/src/reducers/messages.js", "max_forks_repo_name": "oba14/start-chat", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 2, "max_forks_count": null, "avg_line_length": 18.7857142857, "max_line_length": 50, "alphanum_fraction": 0.5513307985}
const initialState = {
  messages: [] 
};

export default (state = initialState, action) => {
  const { type, payload } = action;

  switch (type) {
    case 'NEW_MESSAGE':
    case 'SEND_MESSAGE':
    case 'USER_LEFT':
    case 'INACTIVE_USER':
    case 'NEW_USER_JOINED':
      return {
        ...state,
        messages: [...state.messages, payload]
      }
    case 'DISCONNECT':
    case 'SERVER_DOWN':
    case 'INACTIVE':
      return {...state,
        messages: []  
      };
    default:
      return state;
  }
};
