const intialState = {
  retryImageInfo: [],
};

const clearState = {
  retryImageInfo: [],
};

export default (state = intialState, action) => {
  switch (action.type) {
    case "RETRY_IMAGES":
      return {
        retryImageInfo: [
          ...state.retryImageInfo,
          action.payload.retryImageInfo,
        ],
      };
    case "CLEAR_RETRY_IMAGE_STATE":
      return clearState;
    case "REMOVE_BY_TITLE":
      return {
        retryImageInfo: state.retryImageInfo.filter((item) => {
          return item.title != action.payload;
        }),
      };
    default:
      return state;
  }
};
