import * as React from 'react'; import classNames from 'classnames'; import IReactComponentProps from '../../../common/structures/IReactComponentProps'; import ProgressBar from '../ProgressBar/ProgressBar'; import { TextButton } from '../../buttons/TextButton/TextButton'; import { FunctionGeneric } from '../../../common/structures/Generics'; import styles from './Downloader.scss'; import { Text } from '../../text/Text/Text'; import TimeAgo from 'react-timeago'; const { ipcRenderer } = require('electron'); export interface DownloaderItemProps extends IReactComponentProps { cancelText?: string; downloaded?: number; itemSize?: number; label?: string; onCancel?: FunctionGeneric; onCancelIPCEvent?: string; progress?: number; progressText?: string | number | boolean; truncateProgressText?: boolean; queueIndex?: number; queueLength?: number; showCancel?: boolean; showEllipsis?: boolean; stripes?: boolean; timeStamp?: number; timeStampText?: string; } const DownloaderItem = (props: DownloaderItemProps) => { const { cancelText = 'Cancel download', showEllipsis = true, downloaded, itemSize, label, onCancel, onCancelIPCEvent, progress, progressText, queueIndex, queueLength, showCancel, stripes, truncateProgressText, timeStamp, timeStampText, className, style, id, } = props; const cancelOnClick = (...args: any[]) => { if (onCancelIPCEvent) { ipcRenderer.send(onCancelIPCEvent); } if (onCancel) { return onCancel(...args); } }; return (