import React from 'react'; import { Modal, Button } from 'react-bootstrap'; import filename from '../../util/filename'; import link from '../../helper/link'; import { HistoryItem } from '../../store/queue/types'; import * as ls from '../../util/local-storage'; import BtnCopy from '../btn-copy'; import PopoverConfirm from '../popover-confirm'; interface Props { onHide: () => void } interface State { data: HistoryItem[] } export default class UploadHistory extends React.Component { state: State = { data: [] }; fetch = () => { const data: HistoryItem[] = ls.getByPrefix('history') .sort((a, b) => b.timestamp - a.timestamp) as HistoryItem[]; this.setState({ data }); }; componentDidMount() { this.fetch(); } clear = () => { ls.removeByPrefix('history'); this.fetch(); }; render() { const { onHide } = this.props; const { data } = this.state; return Upload History {data.length > 0 && ( )} {(() => { if (data.length === 0) { return History is empty.; } return <> {data.map((item, i) => (
{filename(item.path)}
))} ; })()}
; } }