export default()

in client/src/reducers/chatReducer.js [38:106]


export default (state = initialState, action) => {
  switch (action.type) {
    case MESSAGE_TO_SEND_CHANGED:
      return {
        ...state,
        messageToSend: action.messageToSend,
      };
    case ADD_SUBSCRIBED_TOPIC:
      return {
        ...state,
        subscribedTopics: [
          ...state.subscribedTopics,
          action.topic,
        ],
      };
    case CLEAR_SUBSCRIBED_TOPICS:
      return {
        ...state,
        subscribedTopics: initialState.subscribedTopics,
      };
    case FETCHING_CHATS:
      return {
        ...state,
        loadingChats: true,
      };
    case RECEIVE_CHATS:
      return {
        ...state,
        allChats: action.chats,
        loadingChats: false,
      };
    case CREATING_CHAT:
      return {
        ...state,
        creatingChat: true,
        error: '',
      };
    case ADD_CHAT:
      return {
        ...state,
        allChats: [
          ...state.allChats,
          action.chat,
        ],
        creatingChat: false,
      };
    case CHAT_ERROR:
      return {
        ...state,
        error: action.error,
      };
    case LOGOUT:
      return {
        ...initialState,
      };
    case FETCHING_USER:
      return {
        ...state,
        fetchingUser: true,
      };
    case NEW_USER:
      return {
        ...state,
        fetchingUser: false,
      };
    default:
      return state;
  }
};