{"size": 803, "ext": "js", "max_stars_repo_path": "src/Reducers/LoadingReducer.js", "max_stars_repo_name": "LinkedMink/necro-automobilia-client", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/Reducers/LoadingReducer.js", "max_issues_repo_name": "LinkedMink/necro-automobilia-client", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/Reducers/LoadingReducer.js", "max_forks_repo_name": "LinkedMink/necro-automobilia-client", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 24.3333333333, "max_line_length": 69, "alphanum_fraction": 0.6363636364}
import {
  LOADING_START,
  LOADING_REPORT,
  LOADING_END,
} from "../Actions/LoadingAction";

const loadingReducer = (state = {}, action) => {
  if (action.type === LOADING_START) {
    if (state && state.isLoading) {
      return state;
    }

    return Object.assign({}, state, {
      isLoading: true,
      percentComplete: action.payload.isProgressable ? 0 : undefined,
      message: action.payload.message,
    });
  } else if (action.type === LOADING_REPORT) {
    let copyState = Object.assign({}, state);
    copyState.percentComplete = action.payload;
    return copyState;
  } else if (action.type === LOADING_END) {
    return Object.assign({}, state, {
      isLoading: false,
      percentComplete: undefined,
    });
  } else {
    return state;
  }
};

export default loadingReducer;
