const DOWNLOAD_STATUSES = ["download_start", "downloading", "download_complete", "download_error", "package_download_complete"];
const INSTALL_STATUSES = ["install_start", "installing", "install_complete", "install_error", "pacakge_install_complete"];

export const isDownloadStatusMessage = (status) => {
  return DOWNLOAD_STATUSES.indexOf(status.msg) > -1;
};

export const isInstallStatusMessage = (status) => {
  return INSTALL_STATUSES.indexOf(status.msg) > -1;
};

export const validateStatusMessage = (status) => {
  if (isDownloadStatusMessage(status)) {
    if (!(status.package_current > -1 && status.package_total > -1)) return false;
    if (status.package_current > status.package_total) return false;
    return true;
  } else if (isInstallStatusMessage(status)) {
    if (!(status.installed > -1 && status.total_files > -1)) return false;
    if (status.installed > status.total_files) return false;
    return true;
  }
  return false;
};
